from django.shortcuts import render
return render(request, 'index.html')
from django.http import HttpResponse
from django.template import loader
from .models import Question
def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {
'latest_question_list': latest_question_list,
}
return HttpResponse(template.render(context, request))
views.py
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
def hello(request):
return render(request, 'hello.html', {})
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('hello', views.hello, name="index")
]
templates/hello.html
<b>fdsfdsfldsjflkdsjkflksja;fdsfdsfldsjflkdsjkflksjasdfkldsjflkdsjfds</b>
<b>>fdlksjfdsljfldsjflkds</b>