[Answer]-Struggling with Django syncdb

1👍

I can’t fully understand which [app] is set in models Meta, but note that django syncdb uses django.db.models.get_apps to find projects’ applications. Latter interspects apps from INSTALLED_APPS, and explicetely tries to load apps’ models module with

models = import_module('.models', app_name)

So applications outside INSTALLED_APPS won’t have tables synced.

Second, django loads all the models with django.db.models.get_apps for each found application, and latter turn introspects AppCache.apps_models (that cache is, as far as I remember, populated with register_models by model constructor). So all the imported models corresponding to valid applications are processed.

I guess you have to ensure that [app] from models._Meta:

  • contains models.py (possibly empty) which will make it a django application;
  • is mentioned in INSTALLED_APPS, to be asseccible with get_apps function.
👤alko

Leave a comment