django create a new app code example
Example 1: django create app
python manage.py startapp
Example 2: start new app in django
$ python manage.py startapp app_name
Example 3: create new django app
python manage.py startapp app_name
Example 4: django basic steps
1º - Create a virtual environment by giving this command:
>> python3 -m venv "name_of_env"
2º - Activate this virtual environment:
>> source "name_of_env"/bin/activate
3º - Now you can install Django:
>> pip3 install django
4º - To initiate a project in Django:
>> django-admin startproject "projectName"
>> cd projectName
5º - To run the server, you need to go to the directory containing
manage.py and from there enter the command:
>> python3 manage.py runserver
6º - To create a basic app in your Django project you need to go
to the directory containing manage.py and from there enter
the command:
>> python3 manage.py startapp "projectAppName"
7º - You need to include the app in our main project so that
urls redirected to that app can be rendered. Move to
"projectName" -> "projectName" -> urls.py and change the
following:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("projectApp.urls")),
]
Example 5: django create app
$ python manage.py startapp polls
Example 6: django make app
...\> django-admin startproject mysite