AttributeError:“ WSGIRequest”对象没有属性“ Get”

时间:2020-09-17 11:56:46

标签: python django

from django.shortcuts import render
from django.http import HttpResponseRedirect
from .models import Quote
from .forms import QuoteForm
from pages.models import Page

def quote_req(request):
submitted = False
    if request.method == 'POST':
        form = QuoteForm(request.POST, request.FILES)
        if form.is_valid():
           form.save()
           
           return HttpResponseRedirect('/quote/?submitted=True')
        else:
            form = QuoteForm()
            if 'submitted' in request.Get:
                submitted = True
                
            return render(request, 'quotes/quote.html', {'form': form, 'page_list': Page.objects.all(), 'submitted':submitted})
    
       

上下文:这是views.py代码,代码看起来正确,但是单击html本地主机上的引号链接会出现上述错误

1 个答案:

答案 0 :(得分:1)

您只有一个错字:

            if 'submitted' in request.Get:

改为使用request.GET