Django 错误:未定义全局名称"请求"



我的django视图遇到了一个小问题。我有一个函数 Identity_FewUpdates,我得到了此错误: global name 'request' is not defined

这很奇怪,因为我有一个看起来非常相似的功能,而且我现在没有遇到问题。

我的功能看起来像:

import requests, os, json, glob
from django.shortcuts import render, reverse, get_object_or_404, render_to_response
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, HttpResponse
from models import Person, CountryField
from BirthCertificate.models import BirthCertificate
from forms import PersonForm, PersonForm2
from django.views.generic.edit import UpdateView
from django.template.loader import get_template
from django.template import Context
from xhtml2pdf import pisa
import Logger, Search, Folds, Docs, Buffer, EnterSearch
from chartit import DataPool, Chart
from django.db.models import Count
from django_countries import countries
import time
from random import randint
from django.contrib import messages 
import Global_variables
@login_required
def Identity_FewUpdates(requests):
    query_social_number = request.GET.get('social_number')
    if query_social_number :
        query_social_number_list = Person.objects.filter(social_number__icontains=query_social_number)   
        print query_social_number_list 
    else :
        query_social_number_list = Person.objects.none() # == []

    form = PersonForm(request.POST or None, instance = query_social_number_list.first())
    query_job = request.GET.get('job')
    context = {
        "query_social_number" : query_social_number,
        "query_social_number_list" : query_social_number_list,
        "query_job" : query_job,
        "form": form
    }
    return render(request, "Update.html", context)

该功能是目前的草稿。您对这个问题有任何想法吗?

django视图函数获取 request参数而不是 requests

@login_required
def Identity_FewUpdates(request):
    query_social_number = request.GET.get('social_number')

相关内容

  • 没有找到相关文章

最新更新