Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#15969 closed Bug (needsinfo)

upgraded 1.1 -> 1.3. Now NULL in ContentType.name 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: no

Description

We are upgrading 1.1 to 1.3.
Oracle back end.
There are NULLS in DJANGO_CONTENT_TYPE.Name and DJANGO_CONTENT_TYPE.Model.
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/models.py 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 by Aymeric Augustin, 13 years ago

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 (http://docs.djangoproject.com/en/dev/ref/models/fields/#null), 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 by mischko, 13 years ago

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