Django South Foreign Keys referring to pks with Custom Fields
- by Rory Hart
I'm working with a legacy database which uses the MySQL big int so I setup a simple custom model field to handle this:
class BigAutoField(models.AutoField):
def get_internal_type(self):
return "BigAutoField"
def db_type(self):
return 'bigint AUTO_INCREMENT' # Note this won't work with Oracle.
This works fine with django south for the id/pk fields (mysql desc "| id | bigint(20) | NO | PRI | NULL | auto_increment |") but the ForeignKey fields in other models the referring fields are created as int(11) rather than bigint(20).
I assume I have to add an introspection rule to the BigAutoField but there doesn't seem to be a mention of this sort of rule in the documentation (http://south.aeracode.org/docs/customfields.html).
Update: Currently using Django 1.1.1 and South 0.6.2