Fixed #7017 -- Minor typo fix in a comment. Thanks FranRuiz.
Also promoted the comment to a docstring and removed some extra spaces. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7422 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
52945a9515
commit
ea87c0df5c
|
@ -35,15 +35,18 @@ class GenericForeignKey(object):
|
||||||
setattr(cls, name, self)
|
setattr(cls, name, self)
|
||||||
|
|
||||||
def instance_pre_init(self, signal, sender, args, kwargs):
|
def instance_pre_init(self, signal, sender, args, kwargs):
|
||||||
# Handle initalizing an object with the generic FK instaed of
|
"""
|
||||||
# content-type/object-id fields.
|
Handles initializing an object with the generic FK instaed of
|
||||||
|
content-type/object-id fields.
|
||||||
|
"""
|
||||||
if self.name in kwargs:
|
if self.name in kwargs:
|
||||||
value = kwargs.pop(self.name)
|
value = kwargs.pop(self.name)
|
||||||
kwargs[self.ct_field] = self.get_content_type(obj=value)
|
kwargs[self.ct_field] = self.get_content_type(obj=value)
|
||||||
kwargs[self.fk_field] = value._get_pk_val()
|
kwargs[self.fk_field] = value._get_pk_val()
|
||||||
|
|
||||||
def get_content_type(self, obj=None, id=None):
|
def get_content_type(self, obj=None, id=None):
|
||||||
# Convenience function using get_model avoids a circular import when using this model
|
# Convenience function using get_model avoids a circular import when
|
||||||
|
# using this model
|
||||||
ContentType = get_model("contenttypes", "contenttype")
|
ContentType = get_model("contenttypes", "contenttype")
|
||||||
if obj:
|
if obj:
|
||||||
return ContentType.objects.get_for_model(obj)
|
return ContentType.objects.get_for_model(obj)
|
||||||
|
|
Loading…
Reference in New Issue