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:
You may be calling a site object before creating site model(before syncdb or migrate)
ex: site = Site.objects.get(id=settings.SITE_ID)
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
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-toolbar
and 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.
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.