Running makemigrations in pluggable nested app using AppConfig

107 views
Skip to first unread message

Tom Evans

unread,
Mar 19, 2018, 11:36:57 AM3/19/18
to django...@googlegroups.com
Hi all

I'm writing a small library which will be bundled together with a
pluggable django app.

The app provides a bunch of different AppConfig instances, the end
user chooses one and pops it in their INSTALLED_APPS:

INSTALLED_APPS += [ 'foo_lib.contrib.django_app.configs.FooAppConfig', ]

All the AppConfigs have their name attribute set to "foo_lib", they
have their path attribute set to the directory containing models.py
and there is a default AppConfig

I have a test project that I'm using to run "makemigrations" and so
on. With INSTALLED_APPS as above, django cannot find any changes for
"foo_lib". If I supply the dotted path to the appconfig to
"makemigrations", I am told:

"App 'foo_lib.contrib.django.configs.FooAppConfig' could not be
found. Is it in INSTALLED_APPS?"

which is quite amusing.

If I replace the path to the appconfig with the dotted path to the
module, and then use "makemigrations django_app", then the migrations
get created, but obviously that seriously sucks.

Furthermore, even with the migration files in place, they are not
actually acted upon when running migrate or tests.


What is the correct way to do this?

Cheers

Tom

Tom Evans

unread,
Mar 19, 2018, 11:55:29 AM3/19/18
to django...@googlegroups.com
In order to make it "work", I imported the models from foo_lib.django
app.models into foo_lib.models. Django was then able to find the
models, and create the migration files.

They are all in the wrong place however, that part of the library
should have nothing to do with django and so this obviously isn't
correct.

I didn't mention it in the first post, this is for
py{27,34,35,36}-dj{108,109,110,111,200}, and developing against
py36-dj200

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages