Raise self.model.DoesNotExist( django.contrib.sites.models.Site.DoesNotExist: Site matching query does not exist
I am implementing google authentication in my website but whenever I run my code I got this error.
Internal Server Error: /
Traceback (most recent call last):
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\Documents\tournament-web\Xoriva\loginpage\views.py", line 6, in home
return render(request, "home.html")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\shortcuts.py", line 25, in render
content = loader.render_to_string(template_name, context, request, using=using)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\loader.py", line 62, in render_to_string
return template.render(context, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\backends\django.py", line 107, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\template\library.py", line 237, in render
output = self.func(*resolved_args, **resolved_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\allauth\socialaccount\templatetags\socialaccount.py", line 21, in provider_login_url
provider = adapter.get_provider(request, provider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\allauth\socialaccount\adapter.py", line 214, in get_provider
app = self.get_app(request, provider=provider, client_id=client_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\allauth\socialaccount\adapter.py", line 297, in get_app
apps = self.list_apps(request, provider=provider, client_id=client_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\allauth\socialaccount\adapter.py", line 242, in list_apps
db_apps = SocialApp.objects.on_site(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\allauth\socialaccount\models.py", line 34, in on_site
site = get_current_site(request)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\sites\shortcuts.py", line 16, in get_current_site
return Site.objects.get_current(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\sites\models.py", line 59, in get_current
return self._get_site_by_id(site_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\contrib\sites\models.py", line 30, in _get_site_by_id
site = self.get(pk=site_id)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rahul\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\db\models\query.py", line 649, in get
raise self.model.DoesNotExist(
django.contrib.sites.models.Site.DoesNotExist: Site matching query does not exist.
[04/Sep/2024 21:56:26] "GET / HTTP/1.1" 500 145886
I am trying to use google authentication. At first I got the 404 page not found but it was my mistake but I don't know how to tackle this. #ignore this site saying to some more details but I don't know what to add more just typing randomly.