Skip to content
Browse files

Use a more explicit check for whether these ids are None.

  • Loading branch information...
1 parent 43073db commit 6bdc47f75ca31d607653eebee3a144631df46aae @alex alex committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/contrib/contenttypes/
4 django/contrib/contenttypes/
@@ -66,7 +66,7 @@ def get_content_type(self, obj=None, id=None, using=None):
if obj is not None:
return ContentType.objects.db_manager(obj._state.db).get_for_model(
obj, for_concrete_model=self.for_concrete_model)
- elif id:
+ elif id is not None:
return ContentType.objects.db_manager(using).get_for_id(id)
# This should never happen. I love comments like this, don't you?
@@ -130,7 +130,7 @@ def __get__(self, instance, instance_type=None):
# performance when dealing with GFKs in loops and such.
f = self.model._meta.get_field(self.ct_field)
ct_id = getattr(instance, f.get_attname(), None)
- if ct_id:
+ if ct_id is not None:
ct = self.get_content_type(id=ct_id, using=instance._state.db)
rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))

0 comments on commit 6bdc47f

Please sign in to comment.
Something went wrong with that request. Please try again.