Opened 6 years ago

Closed 6 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



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 Changed 6 years ago by ksvintsoff@…

comment:2 Changed 6 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed

Duplicate of #13085.

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