I am trying to access my Django application DBG (v1.10) from another python script and have some problems with this.
This is my file and folder structure:
store store __init.py__ settings.py urls.py wsgi.py store_app __init.py__ admin.py apps.py models.py ... db.sqlite3 manage.py other_script.py
According to the Django documentation, my other_script.py looks like this:
import django from django.conf import settings settings.configure(DEBUG=True) django.setup() from store.store_app.models import MyModel
But it generates a runtime error:
RunTimeError: Model class store.store_app.models.MyModel doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I should note that my INSTALLED_APPS list contains store_app as its last element.
If instead I try to pass the configuration as follows:
import django from django.conf import settings from store.store_app.apps import StoreAppConfig settings.configure(StoreAppConfig, DEBUG=True) django.setup() from store.store_app.models import MyModel
I get:
AttributeError: type object 'StoreAppConfig has no attribute 'LOGGING_CONFIG'.
If I edit settings.py and add LOGGING_CONFIG=None , I get another error about another missing attribute, etc.
Any suggestions would be appreciated.
python django
Ben RR Sep 27 '16 at 11:19 2016-09-27 11:19
source share