Opened 3 years ago

Closed 3 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 3 years ago by ksvintsoff@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #13085.

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