Opened 8 years ago

Closed 4 years ago

#6189 closed Uncategorized (invalid)

IntegrityError: Field "may not be NULL" even though blank=True

Reported by: Tyson Tate <tyson@…> Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords: integrityerror, blank, null
Cc: tyson@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Despite adding "blank=True" to my fields, I am unable to save them through the admin interface. I get errors like the following:


Request Method: POST
Request URL:
Django Version: 0.97-pre-SVN-6914
Python Version: 2.4.4
Installed Applications:
Installed Middleware:

File "/opt/local/lib/python2.4/site-packages/django/core/handlers/" in get_response
  82.                 response = callback(request, *callback_args, **callback_kwargs)
File "/opt/local/lib/python2.4/site-packages/django/contrib/admin/views/" in _checklogin
  56.             return view_func(request, *args, **kwargs)
File "/opt/local/lib/python2.4/site-packages/django/views/decorators/" in _wrapped_view_func
  39.         response = view_func(request, *args, **kwargs)
File "/opt/local/lib/python2.4/site-packages/django/contrib/admin/views/" in add_stage
  264.             new_object =
File "/opt/local/lib/python2.4/site-packages/django/db/models/" in save
File "/opt/local/lib/python2.4/site-packages/django/db/models/" in save
  261.                     ','.join(placeholders)), db_values)
File "/opt/local/lib/python2.4/site-packages/django/db/backends/" in execute
  18.             return self.cursor.execute(sql, params)
File "/opt/local/lib/python2.4/site-packages/django/db/backends/sqlite3/" in execute
  133.         return Database.Cursor.execute(self, query, params)

Exception Type: IntegrityError at /admin/events/event/add/
Exception Value: events_event.start_time may not be NULL

With the following model:

class Foo(models.Model):
	the_char = models.CharField(blank=True, maxlength=100)
	the_text = models.TextField(blank=True)
	the_integer = models.IntegerField(blank=True)
	the_time = models.TimeField(blank=True)
	the_date = models.DateField(blank=True)
	the_datetime = models.DateTimeField(blank=True)
	class Admin:
	def __str__(self):
		return "Foo"

The following fields, if left blank, give me the above error:


the_char does not behave unexpectedly (e.g. it allows blank values without throwing an error).

Change History (5)

comment:1 Changed 8 years ago by Tyson Tate <tyson@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I forgot to add that the_text does not behave unexpectedly, either.

comment:2 Changed 8 years ago by ramiro

  • Resolution set to invalid
  • Status changed from new to closed

Use the null option as well.

You are seeing documented behavior, see the descriptions of the null ( and blank field options ( for more details.

comment:3 Changed 4 years ago by ramiro

  • Resolution changed from invalid to fixed

In [16451]:

Fixed #6189 -- Modified test that need Internet access so they use a mock instead. Thanks Gregor Müellegger for the patch.

comment:4 Changed 4 years ago by ramiro

  • Easy pickings unset
  • Resolution fixed deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to Uncategorized
  • UI/UX unset

comment:5 Changed 4 years ago by ramiro

  • Resolution set to invalid
  • Status changed from reopened to closed

Sorry for the noise. I mis typed the ticket number in a commit message.

Note: See TracTickets for help on using tickets.
Back to Top