django-extra-settings icon indicating copy to clipboard operation
django-extra-settings copied to clipboard

Cannot import table because of null constraints

Open joefessenden opened this issue 3 years ago • 4 comments

Python version 3.10

Django version 4.0.6

Package version 0.5.1

Current behavior (bug description) I am trying to import from an Excel file with django-import-export. But, since the models contain blank=True, but not null=True on the fields, the database treats them as required fields and throws a not-null constraint violation. Quickly verified a resolution by changing

value_email = models.EmailField(blank=True, verbose_name=_("Value"))

to

value_email = models.EmailField(blank=True, null=True, verbose_name=_("Value"))

After running makemigrations/migrate, it worked fine.

Expected behavior I want to be able to import tables to new implementations of my application.

joefessenden avatar Aug 17 '22 14:08 joefessenden

@joefessenden thank you for reporting this, could you submit a PR including a test case for this issue please?

fabiocaccamo avatar Aug 17 '22 14:08 fabiocaccamo

@fabiocaccamo Let me work on that. Not sure how I would create a test case for automated testing that relies on the import package that is not part of core django. It's sorta a compatibility issue, I guess, but I do think it's an issue on this side rather than the import side since we allow for blanks in the form and not nulls in the database in the model. (Open to learning I'm wrong about how the models work).

joefessenden avatar Aug 17 '22 16:08 joefessenden

@joefessenden a simple failing test with null values is enought (just to avoid regressions), don't waste too much time on it.

fabiocaccamo avatar Aug 17 '22 17:08 fabiocaccamo

@joefessenden any update?

fabiocaccamo avatar Aug 29 '22 09:08 fabiocaccamo

@joefessenden I close this issue because it is stale, it you continue to contribute on it I will re-open it.

fabiocaccamo avatar Sep 21 '22 10:09 fabiocaccamo