Skip to content

Instantly share code, notes, and snippets.

View zorainc's full-sized avatar

Zorainc zorainc

  • The Netherlands
View GitHub Profile
@zorainc
zorainc / models.py
Created June 28, 2013 10:21
Django model fields for big integer support for primairy and foreign keys
class BigForeignKey(models.ForeignKey):
def db_type(self, connection):
""" Adds support for foreign keys to big integers as primary keys.
"""
rel_field = self.rel.get_related_field()
if (isinstance(rel_field, BigAutoField) or
(not connection.features.related_fields_match_type and
isinstance(rel_field, (BigIntegerField, )))):