Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: how to startapp inside an "apps" folder

Tags:

django

I feel like I must be looking over something obvious because I am having trouble finding anything online about this. But basically here it is, I have a django Project, and I would like to store my apps inside of an apps folder, like thus...

myproject/
    client-side/
        media/
        static/
        templates/
    apps/
        app1/
        app2/
        etc. 
    __init__.py
    manage.py
    etc. (rest of root directory)

but have been unable to figure out how to >>>python manage.py startapp newapp and have it placed into the /apps/ folder. Is it ok to simply ok to startapp at the root level and manually move them into the /apps/ folder?

I greatly appreciate your thoughts and answers.

FYI running python 3.4.2 and Django 1.9.5 on Windows 10

like image 656
Tarrant Avatar asked Jun 29 '16 08:06

Tarrant


1 Answers

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
like image 192
aumo Avatar answered Sep 17 '22 14:09

aumo