I am running my script in the django shell, and the error is coming from these lines:
new_species = Species(genus=new_genus, species=row[4])
new_species.save()
This error:
IntegrityError: NOT NULL constraint failed: birds_species.species_english
I am trying to save information to this model:
class Species(models.Model):
genus = models.ForeignKey(Genus, default=None)
species = models.CharField(max_length=100, default=None)
species_english = models.CharField(max_length=100, default=None, blank=True, null=True)
def __str__(self):
return self.species
I confirm that that migrations are up-to-date because I run the following lines in my django project:
$ python manage.py makemigrations birds
No changes detected in app 'birds'
$ python manage.py migrate
Operations to perform:
Apply all migrations: sessions, admin, polls, auth, contenttypes, birds
Running migrations:
No migrations to apply.
The problem is I am trying to save an object to the Species model, without defining the 1 column species_english. From the model it can be seen that I have default=None, blank=True, null=True which is what I thought we needed to allow null values by default. What do I have wrong here?
I am using the default sqlite3 DB for the DB backend.
Thanks!
EDIT
Here is the migration file contents:
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-17 14:02
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('birds', '0007_speciesfile'),
]
operations = [
migrations.AddField(
model_name='species',
name='species_english',
field=models.CharField(blank=True, default=None, max_length=100, null=True),
),
]
Aucun commentaire:
Enregistrer un commentaire