Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
msapiro opened this issue Sep 14, 2023 · 0 comments
Open

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

msapiro opened this issue Sep 14, 2023 · 0 comments

Comments

@msapiro
Copy link

msapiro commented Sep 14, 2023

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant