ValueError at / The view leads.views.home_page didn't return an HttpResponse object. It returned None instead.
this is my code:
views.py:
from django.shortcuts import render
from django.http import HttpResponse
def home_page(request):
# return HttpResponse('Hello world')
render(request, 'leads/home_page.html')
and here's the urls.py:
from django.contrib import admin
from django.urls import path
from leads.views import home_page
urlpatterns = [
path('admin/', admin.site.urls),
path('', home_page),
]
and here's the template:
CodePudding user response:
The issue is here
def home_page(request): render(request, 'leads/home_page.html')
render
combines a given template with a given context dictionary and returns an HttpResponse
object with that rendered text. So you have to return this HttpResponse
back from view.
def home_page(request): return render(request, 'leads/home_page.html')