#19421 closed Bug (worksforme)
When RelatedModel.__unicode__ fails, InlineModelAdmin are not displayed
Reported by: | benjaoming | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Example code:
class RelatedModel: def __unicode__(self): return self.invalid_property class SomeInline(admin.TabularInline): model = RelatedModel class SomeAdmin(admin.ModelAdmin): inlines = [SomeInline]
When RelatedModel.__unicode__
is called, an exception occurs but is silently ignored. The inlines work fine when adding new objects with SomeAdmin, since __unicode__
is not called here. But when editing an object, the inlines simply disappear!
Expected result: An exception should occur.
Similar experiences here: http://stackoverflow.com/questions/4102241/django-admin-missing-inlines-for-some-records
Change History (5)
comment:1 by , 12 years ago
Component: | Uncategorized → contrib.admin |
---|---|
Type: | Uncategorized → Bug |
comment:2 by , 12 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Confirmed that I'm unable to produce this. Will reopen if I get the scenario right again.
comment:4 by , 12 years ago
I had something like this not long ago, but found it depended on the value of DEBUG. With DEBUG==True, everything worked fine, but with DEBUG==False you got silent failure and the inline simply disappeared.
In my case, it was a UnicodeDecodeError
or UnicodeEncodeError
in the __unicode__
method. I ran out of time debugging in.
comment:5 by , 12 years ago
Yesterday, I also ran out of time trying to debug this on an invalid ascii string ("æøå" instead of u"æøå"). It was fed to a proxy object (ugettext_lazy) inside a template tag, and when the rendering happened, it only failed with DEBUG=False.
Something strange happens in the template compiler, in this case using classy-tags and a template tag from django-cms. Somehow, a DjangoUnicodeDecodeError is lost when DEBUG=True, but replacing that exception (in django.utils.encoding
) with a different exception class, and it gets raised.
Can't reproduce. With models of
and admin registration:
I get a full page exception, reading
Which is exactly what I'd expect to see.
If you can provide models that cause the error, feel free to reopen.