startapp django
- Open a terminal or command prompt.
- Navigate to the directory where you want to create your Django project.
- Run the following command to create a new Django app within your project:
bash
python manage.py startapp your_app_name
- Open the
settings.py
file in your Django project folder. - Locate the
INSTALLED_APPS
section and add the name of your newly created app to the list. It should look like this:
python
INSTALLED_APPS = [
# ...
'your_app_name',
# ...
]
- Create models in the
models.py
file within your app directory. - Run the following command to create initial migrations for your models:
bash
python manage.py makemigrations
- Apply the migrations to create the database tables:
bash
python manage.py migrate
- Create views in the
views.py
file within your app directory. - Define URLs in the
urls.py
file within your app directory. - Include your app's URLs in the project's
urls.py
file. - Create templates in the
templates
folder within your app directory. - Create static files (CSS, JavaScript, etc.) in the
static
folder