1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26085 -- Fixed contenttypes shortcut() view crash with a null fk to Site.

Thanks Fabien Schwob for the initial patch.
This commit is contained in:
dani poni
2016-04-16 09:16:48 +02:00
committed by Tim Graham
parent e494b9ffb6
commit d29d11b026
3 changed files with 46 additions and 4 deletions

View File

@@ -63,9 +63,11 @@ def shortcut(request, content_type_id, object_id):
for field in obj._meta.fields:
if field.remote_field and field.remote_field.model is Site:
try:
object_domain = getattr(obj, field.name).domain
site = getattr(obj, field.name)
except Site.DoesNotExist:
pass
continue
if site is not None:
object_domain = site.domain
if object_domain is not None:
break