1

I just used userena to create user function and everything works fine except it gives this error when I try to log in at admin page, and I'm using django 1.9.7 and userena 2.0.1. I read some old posts and it says to remove 'django.contrib.sites' in INSTALLED_APPS, but userena wouldn't work if I remove it.
here's the error informations:

DoesNotExist at /admin/login/

Site matching query does not exist.

Request Method:     GET
Request URL:    http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version:     1.9.7
Exception Type:     DoesNotExist
Exception Value:    

Site matching query does not exist.


and the settings.py

...
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'polls',
    'MessageBoard',
    'userena',
    'guardian',
    'easy_thumbnails',
    'accounts',
]

...

# email
EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'

# required settings
ANONYMOUS_USER_ID = -1
AUTH_PROFILE_MODULE = 'accounts.MyProfile'
USER_SIGNIN_REDIRECT_URL = '/accounts/%(username)s/'
LOGIN_URL = '/accounts/signin/'
LOGOUT_URL = '/accounts/signout/'
X.ziwei
  • 25
  • 7

2 Answers2

2

This error indicates that you do not have and Sites configured in your database. That can be done with your admin. If you visit http://localhost:8000/admin/sites/site/ you will see that currently the list is empty.

Just add a site and then add

SITE_ID = 1 

into your settings.py

e4c5
  • 52,766
  • 11
  • 101
  • 134
1

Probably here's an answer: I get a “Site matching query does not exist.” exception

Did you forget to set up your SITE_ID setting variable?

deorst
  • 169
  • 1
  • 1
  • 9