Fail Load Data Fixtures Django - integer out of range
Question: I'm developing app using Django and Postgre.

Basically, I create new model on my app.

    
    
    from django.db import models
    from manager.models.state import State
    from django.contrib.auth.models import User
    
    class Address (models.Model):
     address_id = models.AutoField(primary_key=True)
     address_name = models.CharField(max_length=500)
     address_city = models.CharField(max_length=250)
     address_phone = models.IntegerField()
     address_postcode = models.CharField(max_length=10, default = 0)
     state =  models.ForeignKey(State, null=True, blank=True, default = None)
     user = models.ForeignKey(User,  null=True, blank=True, default = None)
    
    def __unicode__(self):
        return self.address_id
    
    @classmethod
    def get_list(cls):
        return list(cls.objects.values())
    

After that I run makemigrations and migrate commandline. All of the models are
created on database normally.

I successfully load data from other json file (fixtures). When I tried to
loaddata address.json on Address table, I got this error.

The Error Message:

    
    
    django.db.utils.DataError: Problem installing fixture '/Users/eeldwin/Documents/Django/fbt/manager/fixtures/address.json': Could not load manager.Address(pk=1): integer out of range
    

The Traceback:

    
    
    Traceback (most recent call last):
      File "manage.py", line 11, in <module>
       execute_from_command_line(sys.argv)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django  /core/management/__init__.py", line 385, in execute_from_command_line
       utility.execute()
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
       self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
       self.execute(*args, **options.__dict__)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
       output = self.handle(*args, **options)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 61, in handle
       self.loaddata(fixture_labels)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 91, in loaddata
        self.load_label(fixture_label)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 148, in load_label
        obj.save(using=self.using)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/core/serializers/base.py", line 173, in save
        models.Model.save_base(self.object, using=using, raw=True)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/base.py", line 617, in save_base
        updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/base.py", line 679, in _save_table
        forced_update)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/base.py", line 723, in _do_update
        return filtered._update(values) > 0
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/query.py", line 600, in _update
        return query.get_compiler(self.db).execute_sql(CURSOR)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1004, in execute_sql
        cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
        cursor.execute(sql, params)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
        return super(CursorDebugWrapper, self).execute(sql, params)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
        six.reraise(dj_exc_type, dj_exc_value, traceback)
      File "/Users/eeldwin/.virtualenvs/fbt/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
    django.db.utils.DataError: Problem installing fixture '/Users/eeldwin/Documents/Django/fbt/manager/fixtures/address.json': Could not load manager.Address(pk=1): integer out of range
    

Here's my fixtures

    
    
    [{
    "model": "manager.address",
    "pk": 1,
    "fields": {
      "address_id": "1",
      "address_name": "Jalan Muara Mas Timur 242",
      "address_city": "Semarang",
      "address_phone": "087832270893",
      "address_postcode": "3122",
      "state": "1"
    }}]
    

However, when I inserted data to database manually, it will run perfectly. Any
ideas what's happened here? Thanks.


Answer: You store `address_phone` as `IntegerField`. Its max value is 2147483647
(<https://docs.djangoproject.com/en/1.7/ref/models/fields/#integerfield>).

But in your fixtures you try to add `087832270893` as `address_phone`, that
why you receive `integer out of range` error.

