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本地主机上的引号链接会出现上述错误
答案 0 :(得分:1)
您只有一个错字:
if 'submitted' in request.Get:
改为使用request.GET
。