{"action":"closed","issue":{"url":"https://api.github.com/repos/stephenmcd/mezzanine/issues/1514","labels_url":"https://api.github.com/repos/stephenmcd/mezzanine/issues/1514/labels{/name}","comments_url":"https://api.github.com/repos/stephenmcd/mezzanine/issues/1514/comments","events_url":"https://api.github.com/repos/stephenmcd/mezzanine/issues/1514/events","html_url":"https://github.com/stephenmcd/mezzanine/issues/1514","id":127714072,"number":1514,"title":"django fails replacing FK \"sites.Site\" string with actual class","user":{"login":"gradel","id":635870,"avatar_url":"https://avatars.githubusercontent.com/u/635870?v=3","gravatar_id":"","url":"https://api.github.com/users/gradel","html_url":"https://github.com/gradel","followers_url":"https://api.github.com/users/gradel/followers","following_url":"https://api.github.com/users/gradel/following{/other_user}","gists_url":"https://api.github.com/users/gradel/gists{/gist_id}","starred_url":"https://api.github.com/users/gradel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gradel/subscriptions","organizations_url":"https://api.github.com/users/gradel/orgs","repos_url":"https://api.github.com/users/gradel/repos","events_url":"https://api.github.com/users/gradel/events{/privacy}","received_events_url":"https://api.github.com/users/gradel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-20T15:58:19Z","updated_at":"2016-01-27T02:22:35Z","closed_at":"2016-01-27T02:22:35Z","body":"After facing this exception in my project could reproduce it on a plain testing install:\r\n\r\n```\r\nInternal Server Error: /sitemap.xml\r\nTraceback (most recent call last):\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/db/models/base.py\", line 401, in __init__\r\n    rel_obj = kwargs.pop(field.name)\r\nKeyError: 'site'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/db/models/base.py\", line 406, in __init__\r\n    val = kwargs.pop(field.attname)\r\nKeyError: 'site_id'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/core/handlers/base.py\", line 149, in get_response\r\n    response = self.process_exception_by_middleware(e, request)\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/core/handlers/base.py\", line 147, in get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/contrib/sitemaps/views.py\", line 16, in inner\r\n    response = func(request, *args, **kwargs)\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/contrib/sitemaps/views.py\", line 67, in sitemap\r\n    protocol=req_protocol))\r\n  File \"/home/gerald/tests/mezzanine/mezzanine/mezzanine/core/sitemaps.py\", line 38, in get_urls\r\n    return super(DisplayableSitemap, self).get_urls(**kwargs)\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/contrib/sitemaps/__init__.py\", line 104, in get_urls\r\n    urls = self._urls(page, protocol, domain)\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/contrib/sitemaps/__init__.py\", line 112, in _urls\r\n    for item in self.paginator.page(page).object_list:\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/contrib/sitemaps/__init__.py\", line 71, in _get_paginator\r\n    return paginator.Paginator(self.items(), self.limit)\r\n  File \"/home/gerald/tests/mezzanine/mezzanine/mezzanine/core/sitemaps.py\", line 27, in items\r\n    return list(Displayable.objects.url_map(in_sitemap=True).values())\r\n  File \"/home/gerald/tests/mezzanine/mezzanine/mezzanine/core/managers.py\", line 366, in url_map\r\n    home = self.model(title=_(\"Home\"))\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/db/models/base.py\", line 408, in __init__\r\n    val = field.get_default()\r\n  File \"/home/gerald/tests/mezzanine/env/lib/python3.4/site-packages/Django-1.9.1-py3.4.egg/django/db/models/fields/related.py\", line 902, in get_default\r\n    if isinstance(field_default, self.remote_field.model):\r\nTypeError: isinstance() arg 2 must be a type or tuple of types\r\n[20/Jan/2016 15:36:37] \"GET /sitemap.xml HTTP/1.1\" 500 123470\r\n```\r\n\r\nself.remote_field.model at this point is the string \"sites.Site\".\r\nThis change in core/models.py worked for me:\r\n\r\n    from django.contrib.sites.models import Site\r\n    site = models.ForeignKey(Site, editable=False)\r\n\r\nTest suite showed no errors."}}