Django is a popular Python web framework designed to help developers rapidly build secure, scalable web applications. Get the skills to build web applications with Django, work with data and forms, and deploy your Django applications in this fast-paced learning path.
- Object-Relational mapping
- URL routing
- HTML templating
- Form handling
- Unit testing
- Admin Site
- Authentication
- Caching
django-admin startproject namefile
- manage.py
- Runs Commands
- __init__.py
- Tells Python that the folder contains Python code
- wsgi.py & asgi.py
- define how web servers can communicate with web applications
- settings.py
- configures the Django project
- urls.py
- routes web requests based on URL
cd foldername
python manage.py runserver
- A component in a Django project
- A folder with a set of Python files
- Each app fits a specific purpose
- Blog
- Forum
- Wiki
python manage.py startapp filename
Every app needs to register on settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'playground' #-> my app
]
჻჻჻჻჻ views.py
request handler
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def say_hello(response):
return HttpResponse('Hello World')
add urls.py on the app folder
from django.urls import path
from . import views
#UrlConf
urlpatterns = [
path('hello/', views.say_hello)
]
჻჻჻჻჻ main folders urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('playground/', include('playground.urls'))
]
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def say_hello(request):
return render(request,'hello.html')