Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create all django apps inside a folder?

Tags:

python

django

Here is my project folder structure:

.venv [virtual environment]
apps
budgetApp
    __init__.py
    settings.py
    urls.py
    wsgi.py
manage.py

When I run the following command python manage.py startapp budget it creates a new folder named budget beside the folder budgetApp.

But I want to create all my apps folder inside the "apps" folder.

like image 766
Kishor Sterling Avatar asked Jun 07 '19 14:06

Kishor Sterling


People also ask

How many apps can a Django project have?

Django comes with six built-in apps that we can examine.

What is Startapp in Django?

From the startapp docs: startapp <app_label> [destination] # startapp command usage. Creates a Django app directory structure for the given app name in the current directory or the given destination. If only the app name is given, the app directory will be created in the current working directory.


2 Answers

  1. At first, you need to create a directory Your_App_Name inside the /apps folder.
  2. After that, run the following command to create the new app
python manage.py startapp Your_App_Name ./apps/Your_Apps_Folder_Name/

Then don't forget to add just created app name in the settings.py like below:

INSTALLED_APPS = [
    ...,
    'apps.Your_App_Name',
]
like image 65
Fatema Tuz Zuhora Avatar answered Oct 09 '22 00:10

Fatema Tuz Zuhora


You can also do it like this

cd apps && django-admin startapp app_name
like image 41
Koushik Das Avatar answered Oct 08 '22 22:10

Koushik Das