0

My models.py file is as following

Class Project(models.Model):
    ABI_choices = (
    ('android-tv/x86','android-tv/x86'),
    ('abi_2', 'google_apis/x86'),
    ('abi_3','google_apis/x86_64'), )
    Screen_size = (
        (1,"Landscape"),
        (2,"Prtarit")
    )
    API_level = (
        ('android-22','Lolipop'),
        ('android-23','kitkat'),
        ('android-25','marshmellow'),
    )
    CPU_delay = (
        (1,0),
        (2,100),
        (3,200),
        (4,300),
        (5,400),
        (6,500),
    )
    Network_delay = (
        (1,20),
        (2,30),
        (3,40),
        (4,50),
        (5,60),
    )
    abi = models.CharField(choices = ABI_choices,max_length=100,default=None)
    screen = models.CharField(choices = Screen_size,max_length=100,default=None)
    version = models.CharField(choices = API_level,max_length=100,default=None)
    GSM = models.CharField(choices = CPU_delay,max_length=100,default=None)
    network_delay = models.CharField(choices = Network_delay,max_length=100,default=None)

but when i try to run migration it show me the following error

django.db.utils.IntegrityError: NOT NULL constraint failed: app_test_project__new.Network_delay

Mutasim Fuad
  • 606
  • 2
  • 12
  • 31

1 Answers1

3

Instead of:

models.CharField(choices = ABI_choices,max_length=100,default=None)

use:

models.CharField(choices = ABI_choices,max_length=100,null=True, blank=True)

for any fields that are not required fields or where you plan on allowing null or empty values.

Risadinha
  • 16,058
  • 2
  • 88
  • 91
  • Then you should update your question with your changes and the new error message. The IntegrityError `NOT NULL` can only happen to fields that have `null=False` (the default), or rather have not `null=True`. Make sure to change that on all of the fields. And I recommend to remove the `default=None`. – Risadinha Nov 21 '16 at 14:54