Powershell mkdir papkaname pipenv install django pipenv shell django-admin startproject projectname(config.)


Download 17.49 Kb.
Sana15.10.2023
Hajmi17.49 Kb.
#1704038
Bog'liq
Eng sodda template yaratish


Powershell

  1. mkdir papkaname

  2. pipenv install django

  3. pipenv shell

  4. django-admin startproject projectname(config .)

  5. django-admin startapp Appname

  6. mkdir templatename(templates)

  7. code .

Visual Studio

  1. template yaratamiz – ya’ni html fayl

  2. nameapp/views.py -

  1. from django.views.generic import TemplateView




  1. class HomePageView(TemplateView):

template_name = 'home.html'


  1. nameapp/urls.py –

  1. from django.urls import path

from .views import HomePageView
2)
urlpatterns =[
path('about/',AboutPageView.as_view(), name = 'about'),
path('',HomePageView.as_view(), name = 'home'),
]


  1. config/urls.py –

  1. from django.urls import path, include




  1. urlpatterns = [

path('admin/', admin.site.urls),
path('',include('pagesapp.urls')),
]


  1. config/settings.py –

'DIRS': [str(BASE_DIR.joinpath('templates'))],

Powershell
python manage.py runserver
Download 17.49 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling