Django South Foreign Keys referring to pks with Custom Fields

Posted by Rory Hart on Stack Overflow See other posts from Stack Overflow or by Rory Hart
Published on 2010-03-22T00:25:17Z Indexed on 2010/03/22 0:31 UTC
Read the original article Hit count: 475

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about django

Related posts about django-south