1:
t = DEBUG_ENGINE.from_string(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
2:
发生服务器错误。请与管理员联系。
我已经在view.py和urls.py中添加了(# -*- coding: utf-8 -*-)
,但仍然无法正常工作。
urlpatterns = [
path('admin/', admin.site.urls),
path('', GeneView.as_view(), name='gene')
]
class GeneView(View):
def get(self, request):
render(request, "index.html")
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.gene_ex',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
仅错误“发生服务器错误。请与管理员联系”。在我的当前页面上。
答案 0 :(得分:0)
您的View
应该返回render
的结果:
class GeneView(View):
def get(self, request):
return render(request, "index.html")
答案 1 :(得分:0)
您使用的是基于类的视图,只需要右键单击template_name ='index.html'即可呈现模板