基于类的TemplateView无法正常工作,请帮助我找到错误
from django.shortcuts import render
from django.views.generic.base import View,TemplateView
from django.http import HttpResponse
# Create your views here.
class home(TemplateView):
template_name = 'index.html'
def get_context_data(self,**kwargs):
context = super().get_context_data(**kwargs)
context['injectme'] = 'injected'
return context
url.py
from django.contrib import admin
from django.urls import path
from django.conf.urls import url,include
from basicapp import views
urlpatterns = [
url(r'^$',views.home.as_view(),name = 'home'),
path('admin/', admin.site.urls),
]
TypeError位于/
预期的str,字节或os.PathLike对象,而不是元组
请求方法:GET
请求网址:http://127.0.0.1:8000/ Django版本:2.2异常
类型:TypeError异常值:预期的str,字节或os.PathLike
对象,而不是元组异常
位置:/anaconda3/envs/mydjangoEnv/lib/python3.7/posixpath.py in
加入,第80行Python
可执行文件:/ anaconda3 / envs / mydjangoEnv / bin / python Python
版本:3.7.3 Python路径:
['/ Users / faiq / Desktop / exercise / CBV / advance',
'/anaconda3/envs/mydjangoEnv/lib/python37.zip',
'/anaconda3/envs/mydjangoEnv/lib/python3.7',
'/anaconda3/envs/mydjangoEnv/lib/python3.7/lib-dynload', '/anaconda3/envs/mydjangoEnv/lib/python3.7/site-packages']服务器
时间:2019年5月8日,星期三23:02:58 +0000