Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 6bdc47f75ca31d607653eebee3a144631df46aae 1 parent 43073db
Alex Gaynor authored

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. 4  django/contrib/contenttypes/generic.py
4  django/contrib/contenttypes/generic.py
@@ -66,7 +66,7 @@ def get_content_type(self, obj=None, id=None, using=None):
66 66
         if obj is not None:
67 67
             return ContentType.objects.db_manager(obj._state.db).get_for_model(
68 68
                 obj, for_concrete_model=self.for_concrete_model)
69  
-        elif id:
  69
+        elif id is not None:
70 70
             return ContentType.objects.db_manager(using).get_for_id(id)
71 71
         else:
72 72
             # This should never happen. I love comments like this, don't you?
@@ -130,7 +130,7 @@ def __get__(self, instance, instance_type=None):
130 130
             # performance when dealing with GFKs in loops and such.
131 131
             f = self.model._meta.get_field(self.ct_field)
132 132
             ct_id = getattr(instance, f.get_attname(), None)
133  
-            if ct_id:
  133
+            if ct_id is not None:
134 134
                 ct = self.get_content_type(id=ct_id, using=instance._state.db)
135 135
                 try:
136 136
                     rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))

0 notes on commit 6bdc47f

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