Django - manage.py sql APPNAME not generating model SQL -
i have relatively large flat application i'm working on. maintain separation of concerns, i've split model , view files auth_models
, dashboard_models
, taxonomy_models
, more. these have been placed in folder structure as
appname/ app/ models/ __init__.py auth_models.py dashboard_models.py taxonomy_models.py ... views/ __init__.py dashboard_views.py taxonomy_views.py ...
my app/models/__init__.py
has following:
from auth_models import * dashboard_models import * taxonomy_models import *
however, when run ./manage.py sql app
, no output whatsoever. no warnings, nothing @ all.
the reason question i'm implementing database modification , migration in south cannot handle several aspects. i'm starting on fresh schema , later implement data conversion script migrate existing dataset. this, need schema create model tables.
see this answer.
django makes assumptions app name path in models live, you're forced in situation add app label every imported model this:
class mymodel(model): # model fields class meta: app_label = 'app'
background:
as of writing, django has following code detect app label model:
if getattr(meta, 'app_label', none) none: # figure out app_label looking 1 level up. # 'django.contrib.sites.models', 'sites'. model_module = sys.modules[new_class.__module__] kwargs = {"app_label": model_module.__name__.split('.')[-2]}
from this, see infers app_label
modules name, may exist deep in app hierarchy.
Comments
Post a Comment