diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-15 01:13:52 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-15 01:13:52 +0000 |
| commit | ea87c0df5c0f2f1e7db6bbb2fc61141cec62e4f5 (patch) | |
| tree | 9aab7c32733e41efe9db704687dfa248f122e1ab | |
| parent | 52945a95158dabdb8b381991fe9c1a3b218b9b52 (diff) | |
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
| -rw-r--r-- | django/contrib/contenttypes/generic.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py index 25cef95acf..1282cc3df8 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -35,15 +35,18 @@ class GenericForeignKey(object): setattr(cls, name, self) 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: value = kwargs.pop(self.name) kwargs[self.ct_field] = self.get_content_type(obj=value) kwargs[self.fk_field] = value._get_pk_val() 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") if obj: return ContentType.objects.get_for_model(obj) @@ -61,10 +64,10 @@ class GenericForeignKey(object): return getattr(instance, self.cache_attr) except AttributeError: rel_obj = None - + # Make sure to use ContentType.objects.get_for_id() to ensure that # lookups are cached (see ticket #5570). This takes more code than - # the naive ``getattr(instance, self.ct_field)``, but has better + # the naive ``getattr(instance, self.ct_field)``, but has better # 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) |
