Powershell
mkdir papkaname
pipenv install django
pipenv shell
django-admin startproject projectname(config .)
django-admin startapp Appname
mkdir templatename(templates)
code .
Visual Studio
template yaratamiz – ya’ni html fayl
nameapp/views.py -
from django.views.generic import TemplateView
class HomePageView(TemplateView):
template_name = 'home.html'
nameapp/urls.py –
from django.urls import path
from .views import HomePageView
2)
urlpatterns =[
path('about/',AboutPageView.as_view(), name = 'about'),
path('',HomePageView.as_view(), name = 'home'),
]
config/urls.py –
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('pagesapp.urls')),
]
config/settings.py –
'DIRS': [str(BASE_DIR.joinpath('templates'))],
Powershell
python manage.py runserver
Do'stlaringiz bilan baham: |