Skip to content

Instantly share code, notes, and snippets.

@mozillalives
mozillalives / Django_unsignedBigint.py
Last active May 18, 2018 17:45 — forked from pinfort/Django_unsignedBigint.py
Django database fields for using unsigned bigint column
from django.db import models
from django.utils.translation import ugettext
class PositiveBigIntegerRelDbTypeMixin(models.fields.PositiveIntegerRelDbTypeMixin):
def rel_db_type(self, connection):
if connection.features.related_fields_match_type:
return self.db_type(connection)
else:
return models.BigIntegerField().db_type(connection=connection)