Reputation: 29
I'm currently running django version 1.11 and I want to create a blog. I am at the process where I create a function based view to display html content. I keep running into this error.
File "/Users/Fanonx/Desktop/xventureblog/src/xventureblog/urls.py", line 21, in <module>
url(r'^admin/', include(admin.site.urls)),
NameError: name 'include' is not defined
Here is my code for views.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def post_home(request):
return HttpResponse("<h1>Hello<h1>")
here is my code for urls.py
from django.conf.urls import url
from django.contrib import admin
from posts.views import post_home
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^posts/$', post_home),
]
Upvotes: 1
Views: 4793
Reputation: 10792
You didn't import include from django.conf.urls
, hence the exception you received (it's quite self-explanatory if you break it down). Your urls.py
first line should be:
from django.conf.urls import url, include
Upvotes: 3