Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15969 closed Bug (needsinfo)

upgraded 1.1 -> 1.3. Now NULL in causes error in admin

Reported by: Scott Chapman <scott@…> Owned by: nobody
Component: contrib.contenttypes Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:


We are upgrading 1.1 to 1.3.
Oracle back end.
When I go to the Admin interface and try to change the user, an error comes up:

TemplateSyntaxError at /admin/auth/user/82/

Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found

Request Method: 	GET
Request URL: 	http://..../admin/auth/user/82/
Django Version: 	1.3
Exception Type: 	TemplateSyntaxError
Exception Value: 	

Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found

Exception Location: 	..../django/contrib/auth/ in __unicode__, line 89
Python Executable: 	/usr/bin/python
Python Version: 	2.4.3

The new version of Django has None for the value in the ContenetType.Name. In version 1.1, it was an empty string, which would Unicode() correctly.

Change History (2)

comment:1 Changed 7 years ago by Aymeric Augustin

Resolution: needsinfo
Status: newclosed

ContentType is defined like this:

class ContentType(models.Model):
    name = models.CharField(max_length=100)
    app_label = models.CharField(max_length=100)
    model = models.CharField(_('python model class name'), max_length=100)

It does not allow null or empty values in name and model, and this has not changed between 1.1 and 1.3.

So the columns should be NOT NULL in the database and blank values shouldn't be allowed.

NB: it seems that empty strings will be stored as NULL on Oracle (, but that is not relevant here: neither NULL nor "" are allowed.

I really don't know how you ended up with NULL values in this table. Can you investigate to see how this happened? Did you modify the table manually? What is the current schema?

At this point, there isn't enough information to reproduce the problem.

comment:2 Changed 7 years ago by mischko

The NULL was inserted manually, bypassing the model framework. Sorry for the line noise here. Kindly disregard.

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