Brobin / django-seed

:seedling: Seed your Django database with fake data
MIT License
688 stars 86 forks source link

field 'some field' cannot be null #19

Closed coolharsh55 closed 8 years ago

coolharsh55 commented 9 years ago

django-seed does not fill in this field, and instead raises an error saying the field cannot be null.

Command used: (output does not change regardless of optional parameters)

seeder.add_entity(LifeXIdea, 1, {
    'modified': timezone.now,
})

Model field in lifeX.models.LifeXIdea:

modified = models.DateTimeField(blank=True,)

Traceback:

Traceback (most recent call last):
  File "/Volumes/Data/CODE/harshp.com/source/sitedata/tests.py", line 57, in setUp
    insertedPKs = seeder.execute()
  File "/Volumes/Data/CODE/harshp.com/lib/python2.7/site-packages/django_seed/seeder.py", line 133, in execute
    entity = self.entities[klass].execute(using, inserted_entities)
  File "/Volumes/Data/CODE/harshp.com/lib/python2.7/site-packages/django_seed/seeder.py", line 71, in execute
    setattr(obj, field, format(inserted_entities))
  File "/Volumes/Data/CODE/harshp.com/lib/python2.7/site-packages/django_seed/seeder.py", line 39, in build_relation
    raise SeederException(message)
SeederException: Field lifeX.LifeXIdea.modified cannot be null
Brobin commented 9 years ago

I think this may be a foreign key issue related to #11

coolharsh55 commented 9 years ago

I think so too, but I cannot figure out why the issue gives such an unrelated message?

Brobin commented 9 years ago

Hey @coolharsh55, I had a little time to work on this issue. Sorry it has taken so long, but I think I have the solution in the dependency_sorting branch.

Brobin commented 8 years ago

Resolved with #26

CoCreate-SMWLucasO commented 1 month ago

@Brobin This issue still exists for foreign key relations