为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

临摹微笑 2021-09-11 17:41:52
定义 url 时,我不断收到一个奇怪的错误:AttributeError at /'tuple' object has no attribute 'get'Request Method: GETRequest URL:    http://localhost:51942/Django Version: 2.1.3Exception Type: AttributeErrorException Value:    'tuple' object has no attribute 'get'这是我的网址:from django.contrib import adminfrom django.urls import pathfrom saeed import viewsurlpatterns = [    path('admin/', admin.site.urls),    path('', views.index, name="index"),]这是我的观点:from django.shortcuts import renderdef index(request):    return render,"index.html"请通知我。谢谢,赛义德
查看完整描述

1 回答

?
跃然一笑

TA贡献1826条经验 获得超6个赞

您应该将视图更改为:


from django.shortcuts import render


def index(request):

    return render(request, "index.html")


查看完整回答
反对 回复 2021-09-11
  • 1 回答
  • 0 关注
  • 141 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号