If you haven't created a Django project yet, follow the steps to set up a project. If you have a project, activate the virtual environment and navigate to your project's directory.
cd my_django_project
source venv/bin/activate
On Windows, activate the virtual environment with:
venv\Scripts\activate
Django has a built-in command to create new apps within a project. To create a new app, run:
python manage.py startapp myapp
Replace '"myapp"' with the name of your app. This command creates a new directory named "myapp" within your Django project with the following structure:
After creating the app, you need to inform Django that it exists. Open myproject/settings.py (where "myproject" is the name of your Django project) and find the INSTALLED_APPS list. Add your new app's name to this list:
INSTALLED_APPS = [
# Existing apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Add your app here
'myapp', # Name of the app you created
]