猿问

尝试为索引视图定义 url 时出现属性错误

定义 url 时,我不断收到一个奇怪的错误:


AttributeError at /

'tuple' object has no attribute 'get'

Request Method: GET

Request URL:    http://localhost:51942/

Django Version: 2.1.3

Exception Type: AttributeError

Exception Value:    

'tuple' object has no attribute 'get'

这是我的网址:


from django.contrib import admin

from django.urls import path


from saeed import views



urlpatterns = [


    path('admin/', admin.site.urls),


    path('', views.index, name="index"),



]

这是我的观点:


from django.shortcuts import render

def index(request):

    return render,"index.html"

请通知我。谢谢,赛义德


临摹微笑
浏览 142回答 1
1回答

跃然一笑

您应该将视图更改为:from django.shortcuts import renderdef index(request):    return render(request, "index.html")
随时随地看视频慕课网APP

相关分类

Python
我要回答