The initialization process of models seems to be good step in cleaning many problems, but I don't understant why I can't import models.The usage of the model should raise exception when it is not loaded/initialized, but not importing a model class!
It is very good that app initialization is done within a special stage. I remember many problems related to imports and I'm happy that they will not occur anymore.
I understand what is done and what for. Just wondering about possibility to do some kind of late initialization.
I see that models registering is done in metaclasses, I see that app_name is used by model fields to construct related names, and so on... I've tried to move model class registration after app init, but it failed because of lot of early calls for app_name. Let's forget that for a while.
My problem is simple. When I'm developing a reusable app I'd like to expose common/main objects in the package namespace. This is done via imports from package modules. These objects often are not placed in Django modules like models.py. But they are using models via importing them into their module's namespace (typically at the top of the file). This makes chain of imports when you're trying to expose something at the package level. Exposed objects makes high-level interface to the app.
I would like to do same thing using Django 1.9+. I can set app_name explicit, I suppose, I can encapsulate model imports in methods (quite ugly when readability counts), or build proxies.
I'd glad to hear your suggestions for that.
Thanks,
Marcin
Just wondering about possibility to do some kind of late initialization.
I am getting this error while i create a newapp and integrate in the setting and urls file in sample projectC:\Users\RaoKaleemullah\Desktop\django-tutorial\sample>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>execute_from_command_line(sys.argv)File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\core\management\__init__.py", line 350, in execute_from_command_lineutility.execute()File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\core\management\__init__.py", line 342, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\core\management\__init__.py", line 176, in fetch_commandcommands = get_commands()File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\utils\lru_cache.py", line 100, in wrapperresult = user_function(*args, **kwds)File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\core\management\__init__.py", line 71, in get_commandsfor app_config in reversed(list(apps.get_app_configs())):File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\apps\registry.py", line 137, in get_app_configsself.check_apps_ready()File "C:\Users\RaoKaleemullah\Anaconda2\lib\site-packages\django-1.9-py2.7.egg\django\apps\registry.py", line 124, in check_apps_ready