Django: relation “django_site” does not exist

前端 未结 10 1365
北荒
北荒 2020-12-05 10:30

I am running a test django server on aws and I just installed django-userena and when I try to signup a user upon clicking submit, I get the following message:

相关标签:
10条回答
  • 2020-12-05 10:53

    I recently ran into this issue (Django 1.8.7) even with SITE_ID = 1 in my settings. I had to manually migrate the sites app before any other migrations:

    ./manage.py migrate sites
    ./manage.py migrate
    
    0 讨论(0)
  • 2020-12-05 10:53

    I have the same problem and fixed it like this:

    1. add SITE_ID=1 into settings.py
    2. run this command :

      python manage.py migrate
      
    0 讨论(0)
  • 2020-12-05 10:56

    if you are getting this error when deploying you django app to Heroku, make sure you have run:

    heroku run python manage.py migrate

    This worked for me

    0 讨论(0)
  • 2020-12-05 10:59

    Going to leave this here for future me:

    python manage.py makemigrations allauth

    This worked for me, I forgot why, took me too long to figure out how I fixed this the first time

    Edit: makemigrations sometimes doesnt make 3rd party things like allauth which some of my projects use, so I have to specify those ones

    0 讨论(0)
  • 2020-12-05 11:06

    A horrible code lead to this error for me. I had a global variable to get the current site

    SITE = Site.objects.get(pk=1)

    this was evaluated during migration and lead to the error.

    0 讨论(0)
  • 2020-12-05 11:10

    I got this error while working with django-cookiecutter, django-allauth and django-rest-auth

    I literally spent 5 hours pulling my hair out. Eventually gave in and started to comment out bit by bit

    What worked for me was commenting out both pre-configured url paths (they come with cookiecutter Django):

    # User management
    path("users/", include("yourapp.users.urls")),
    path("accounts/", include("allauth.urls")),
    

    After that migrations worked.

    I uncommented it and my app has worked ever since. It was only for the initial migration

    Hope it helps someone!

    0 讨论(0)
提交回复
热议问题