summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-07-08 12:44:17 +1000
committerAlex Gaynor <alex.gaynor@gmail.com>2013-07-08 12:44:17 +1000
commit6bdc47f75ca31d607653eebee3a144631df46aae (patch)
tree15fdb07ae4baff76a5e66570a5c6b094053dc9b2
parent43073dbd76a31b3c171877dc2edf9d177a10531f (diff)
Use a more explicit check for whether these ids are None.
-rw-r--r--django/contrib/contenttypes/generic.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 04d4894b8a..6f120f82e0 100644
--- a/django/contrib/contenttypes/generic.py
+++ b/django/contrib/contenttypes/generic.py
@@ -66,7 +66,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
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)
else:
# This should never happen. I love comments like this, don't you?
@@ -130,7 +130,7 @@ class GenericForeignKey(six.with_metaclass(RenameGenericForeignKeyMethods)):
# 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)
try:
rel_obj = ct.get_object_for_this_type(pk=getattr(instance, self.fk_field))