So, I'm running now on Django 1.7rc2, have couple of models created and when I run ./manage.py shell, everything works perfectly, however, as soon as I added tastypie (I have the last stable version, 0.11.1) to the INSTALLED_APPS, I got this exception on ./manage.py shell
Traceback (most recent call last):
File "manage.py", line 16, in <module>
execute_from_command_line(sys.argv)
File "/home/miki/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/miki/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/miki/project/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/miki/project/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/miki/project/local/lib/python2.7/site-packages/django/apps/config.py", line 197, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/miki/project/local/lib/python2.7/site-packages/tastypie/models.py", line 31, in <module>
from tastypie.compat import AUTH_USER_MODEL
File "/home/miki/project/local/lib/python2.7/site-packages/tastypie/compat.py", line 13, in <module>
User = get_user_model()
File "/home/miki/project/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 136, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/home/miki/project/local/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
self.check_models_ready()
File "/home/miki/project/local/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
I've googled a bit and only have encountered this exception where the script is run from standalone script, but this is not the case. Also, in the django documentation it says
Another common culprit is django.contrib.auth.get_user_model(). Use the AUTH_USER_MODEL setting to reference the User model at import time.
but I have that settings set up in my settings
# The model to use to represent a User.
AUTH_USER_MODEL = 'customuser.CustomUser'
Is the error somewhere in my code or is the problem in tastypie?
The Daniels answer led me to the solution, but since than there was a new version of tastypie, that solves the problem.