Given a sub-directory named "apps" for all django applications, the following steps are used to setup the sub-directory and create apps.
1 create app sub folder - "apps"
mkdir apps
touch apps/__init__.py
2 add app to sub folder:
mkdir apps/myapp
python manage.py startapp myapp apps/myapp
3 update apps.py in apps/myapp to have the name include 'apps.' as shown below:
class MyappConfig(AppConfig):
# optional, add default auto field
default_auto_field = 'django.db.models.BigAutoField'
# set location of app using sub dir
name = 'apps.myapp'
# optional, add name of app
verbose_name = 'My App Verbose Name'
4 Install myapp like this:
INSTALLED_APPS = (
...
'apps.myapp',
)
5 Create urls like this:
urlpatterns = patterns('',
url(r'^myapp', include('apps.myapp.urls')),
...
)
6 make migrations like this:
makemigrations myapp --pythonpath='apps'
Posted by Cuauhtemoc to Python Django (2018-06-19 13:38)