Opened 12 years ago

Closed 12 years ago

#19494 closed Bug (duplicate)

Defining __nonzero__ (or __len__) on model makes it impossible to use in GenericForeignKey

Reported by: anonymous Owned by: nobody
Component: contrib.contenttypes 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: no UI/UX: no

Description

django/contrib/contenttypes/generic.py:
GenericForeignKey.get_content_type:

def get_content_type(self, obj=None, id=None, using=None):

# Convenience function using get_model avoids a circular import when
# using this model
ContentType = get_model("contenttypes", "contenttype")
if obj:

return ContentType.objects.db_manager(obj._state.db).get_for_model(obj)

if obj: case does not execute for any object which has False boolean value.

Change History (2)

comment:1 by ksvintsoff@…, 12 years ago

comment:2 by Ramiro Morales, 12 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #13085.

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