Runtime error:App registry isn't ready yet

会有一股神秘感。 提交于 2019-11-30 03:54:37
AKrishan

[django 1.7] The Standalone script you wish to run, import django and settings like below

import os

import django

[...]


if __name__ == '__main__':  
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')

    django.setup()

This is a known and intended behaviour according to Django's 1.7 release notes, under the "startup sequence" clause:

Another common culprit is django.contrib.auth.get_user_model(). Use the AUTH_USER_MODEL setting to reference the User model at import time.

and that should do the trick

for reference: https://docs.djangoproject.com/en/dev/releases/1.7/#app-loading-changes

I found out that if I run populate through the manage.py shell with the execfile() command then it runs properly. Everything needed to be setup before I start modifying the database or run outside code. Thanks to lanzz for the hint.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!