首页 文章

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

提问于
浏览
-1

我在定义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"

请通知我 . 谢谢,赛义德

1 回答

  • 0

    您应该将视图更改为:

    from django.shortcuts import render
    
    def index(request):
        return render(request, "index.html")
    

相关问题