django-admin startproject salom
app yaratish - python manage.py startapp sahifa
import os
installed_apps ga quyidagi kirtiladi: sahifa
sahifadi viewsga o’tamiz va httm modulini yuklab olamiz.
from django.http import HttpResponse
def HomePageView(request):
return HttpResponse('Kamalova Nilufar')
sahifaning ichiga urls.py ni ochamiz
from django.urls import path
from .views import HomePageView
urlfoydalanuvchi=[
path('',HomePageView,name='home')
]
glavni urlsga qo’shaib qo’yamiz: path('',include('sahifa.urls'))
ishga tushirish python manage.py runserver
HTML shablonlari (templateni ko’rsatish) :
'DIRS': [os.path.join(BASE_DIR,'shablon')],
{% extends 'home.html' %}
{%block contend %}
<h2 style="color:green;"> Biz haqimizdah2>
{% endblock content%}
Do'stlaringiz bilan baham: |