django-sites icon indicating copy to clipboard operation
django-sites copied to clipboard

Setting SITE_ID = 0 fails on GET of /accounts/social/connections/

Open msapiro opened this issue 1 year ago • 0 comments

In most contexts with multiple sites, setting SITE_ID = 0 associates the site with the requesting host and this works well. The Django docunentation at https://docs.djangoproject.com/en/4.2/ref/contrib/sites/ seems to indicate this should work. It says: The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file. If the setting is omitted, the get_current_site() function will try to get the current site by comparing the domain with the host name from the request.get_host() method. However, upon GET of /accounts/social/connections/, tthe following is thrown:

ERROR 2023-09-14 17:41:38,047 log 3672731 140012244460944 Internal Server Error: /accounts/social/connections/
Traceback (most recent call last):
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/ddtrace/contrib/trace_utils.py", line 162, in wrapper
    return func(mod, pin, wrapped, instance, args, kwargs)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/ddtrace/contrib/django/patch.py", line 213, in wrapped
    return func(*args, **kwargs)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/ddtrace/contrib/trace_utils.py", line 162, in wrapper
    return func(mod, pin, wrapped, instance, args, kwargs)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/ddtrace/contrib/django/patch.py", line 351, in traced_template_render
    return wrapped(*args, **kwargs)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 214, in render
    nodelist.append(node.render_annotated(context))
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 517, in render
    values = {key: val.resolve(context) for key, val in self.extra_context.items()}
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 517, in <dictcomp>
    values = {key: val.resolve(context) for key, val in self.extra_context.items()}
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/models.py", line 153, in get_provider_account
    return self.get_provider().wrap_account(self)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/models.py", line 147, in get_provider
    provider = self._provider = adapter.get_provider(
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/adapter.py", line 204, in get_provider
    app = self.get_app(request, provider=provider)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/adapter.py", line 282, in get_app
    apps = self.list_apps(request, provider=provider, client_id=client_id)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/adapter.py", line 231, in list_apps
    db_apps = SocialApp.objects.on_site(request)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/allauth/socialaccount/models.py", line 26, in on_site
    site = get_current_site(request)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/contrib/sites/shortcuts.py", line 13, in get_current_site
    return Site.objects.get_current(request)
  File "/opt/mailman/mm/venv/lib/python3.9/site-packages/django/contrib/sites/models.py", line 62, in get_current
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting or pass a request to Site.objects.get_current() to fix this error.

msapiro avatar Sep 14 '23 18:09 msapiro