1

I have the following Bank model:

from django.db import models

class Bank(models.Model):
    id = models.BigIntegerField(primary_key=True)
    name = models.CharField(unique=True, max_length=255)
    identifier = models.CharField(unique=True, max_length=255)
    created_at = models.DateTimeField()
    updated_at = models.DateTimeField()
    class Meta:
        db_table = u'bank'
        app_name = 'mcif'

Now look at this:

>>> from mcif.models import *
>>> b = Bank()
>>> b.name = "wee"
>>> b.identifier = "wee"
>>> b.save()
>>> b.id
>>>

If I understand how Django works, that Bank object is supposed to get updated with the id of the saved record. Any idea why this isn't happening?

Jason Swett
  • 43,526
  • 67
  • 220
  • 351

1 Answers1

0

Its a problem in Django when dealing with BigInt as Autoincrementing PK. Maybe this code snippet helps you solve this issue. Its a makeshift solution

Perpetualcoder
  • 13,501
  • 9
  • 64
  • 99