[Django]-Django: how to startapp inside an "apps" folder

43πŸ‘

βœ…

You can specify the app’s directory as a second parameter:

python manage.py startapp <app_name> <app_directory>

Note that no directory will be created, the app’s files will be created directly in the specified directory. Example:

python manage.py startapp myapp apps/myapp

Will result in the given directory structure:

apps
└── myapp
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ admin.py
    β”œβ”€β”€ apps.py
    β”œβ”€β”€ migrations
    β”‚Β Β  └── __init__.py
    β”œβ”€β”€ models.py
    β”œβ”€β”€ tests.py
    └── views.py

Also note that the command won’t create the directory for you.

Edit: as another (now deleted) answer pointed out, running the command from the apps directory would also work:

cd apps
python ../manage.py startapp myapp
πŸ‘€aumo

4πŸ‘

You can also use the django-admin command as well.

cd apps && django-admin startapp app_1

this will work as well

πŸ‘€Koushik Das

Leave a comment