Django: relation “django_site” does not exist

前端 未结 10 1366
北荒
北荒 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 11:12

    You may be calling a site object before creating site model(before syncdb or migrate)

    ex: site = Site.objects.get(id=settings.SITE_ID)

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

    I'm late, but I ran into the same issue with django v 1.11.

    The issue was that I was rebuilding a model outside the normal def() and in a form() [I use the models for a choice] The traceback should have the .py file listed

    e.g.

     File "filepath/views.py", line 67, in <module>
        some_variable = some_model.objects.get(name ='name')
    

    So I had to comment it out to rebuild my migrations

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

    This issue might be caused by one of the apps you're using. If you check the traceback carefully, you might already find the delinquent.

    I had those issues using django-debug-toolbarand zinnia.

    If you are using the django-debug-toolbar this might be a solution:

    Try following the steps for the explicit setup: http://django-debug-toolbar.readthedocs.org/en/1.2.2/installation.html#explicit-setup

    Alternatively remove debug_toolbar from your INSTALLED APPS.

    If that doesn't help or if another app is causing the issue, try to temporarily remove all imports (e.g. installed app, urls, custom views, settings), which are displayed in the traceback.

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

    I experienced the same problem with creating a new empty database for my project (which uses zinnia)

    Running 'manage migrate site' before 'manage migrate' did not solve anything. It seems that the complete project was loaded before any table creating was done.

    I resolved to catching the errors that importing the zinnia releated app produced.

    e.g.: in the urls.py of the app

    urlpatterns = None
    app_name = 'something'
    
    try:
        from .views import MyEntryCreate
    
    
        urlpatterns = [
    
        url(r'^blogentry/create/$',
            login_required(MyEntryCreate.as_view()),
            name='zinnia_entry-add'),
    
        ]
    except Exception as e:
        logger.error(app_name+" Error urls: "+str(e))
        urlpatterns = []
    

    Had to do something like that elsewhere in that app, and 'manage migrate' worked again.

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