Code

Opened 5 years ago

Closed 5 years ago

#9688 closed (invalid)

Date*Field IntegrityError 1048 column cannot be null

Reported by: pierpaolodf Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: DateField DateTimeField null IntegrityError 1048
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have the following model:

...

date=models.DateField?(blank=True, null=True)

...

As I try to add a new record in admin it throws an IntegrityError 1048 saying that the DateField? cannot be null, even though it is set to be both blank and null.

I tried also programmatically in shell and it throws the same error.

I'm working on Django SVN release 9525, Python 2.5, MySql? 5.0 and Apache 2.2 with modpython.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

I'm guessing you added one or both those options after the syncdb that created the table. In which case you need to manually update the table definition to say nulls are allowed, since changes like this that you made to your model definitions post-syncdb aren't reflected in the DB automatically. Reopen if you've got a recreatable scenario where a blank=True,null=True DateField is created by syncdb without allowing nulls at the DB level, but I doubt that is what is happened.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.