start new app in django
To start a new app in Django, follow these steps:
- Open your command prompt or terminal.
- Navigate to the directory where you want to create your Django project.
- Create a new Django project by typing the following command:
django-admin startproject project_name
. - Replace
project_name
with the name you want to give to your project. Make sure to use lowercase letters and underscores instead of spaces. - Once the project is created, navigate into the project folder using the
cd
command:cd project_name
. - Inside the project folder, create a new Django app by running the following command:
python manage.py startapp app_name
. - Replace
app_name
with the name you want to give to your app. Again, use lowercase letters and underscores instead of spaces. - After the app is created, you need to include it in your project's settings. Open the
settings.py
file located in the project folder and find theINSTALLED_APPS
variable. - Add the name of your app to the list of installed apps. For example, if your app is called "myapp", add
'myapp'
to the list of installed apps. - Save the
settings.py
file. - You can now start working on your app by creating models, views, and templates.
That's it! You have successfully started a new app in Django. Remember to run python manage.py runserver
to start the development server and see your app in action.