python - building reusable package in django -
am trying build reusbale package django, package contains multiple application since project quite large.
so, structure, has apps folder , inside there multiple apps payment, product, account..etc
as trying make project re-usable, created in different location of source project , did symbolic link root folder in source project.
now, when want install apps, have write them 1 one in installed_apps
installed_apps = ('package.apps.store', 'package.apps.product', 'package.apps.delivery', 'package.apps.payment', 'package.apps.store', 'package.apps.cart', 'package.apps.tax')
is there way, can include 'package' in installed apps , perhaps use package init load other modules?
i tried doing in package/__init__.py
from django.conf import settings user_settings package.conf import settings user_settings.installed_apps = user_settings.installed_apps + settings.installed_apps
but didn't work, 1 can advise on this?
i believe once "from django.conf import settings" line has executed, settings immutable.
what invert logic bit. in package/__init__.py. like:
def get_apps(): apps = ( 'apps.store', 'apps.other', ... ) return [__name__ + '.' + x x in apps]
then just:
installed_apps += get_apps()
in settings.py. quite bit keep our settings.py manageable , seems work quite well.
Comments
Post a Comment