Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 无法获取同一行中的下拉菜单,它仅在提交表单时写入一次_Django_Django Models_Django Views_Django Forms_Django Templates - Fatal编程技术网

Django 无法获取同一行中的下拉菜单,它仅在提交表单时写入一次

Django 无法获取同一行中的下拉菜单,它仅在提交表单时写入一次,django,django-models,django-views,django-forms,django-templates,Django,Django Models,Django Views,Django Forms,Django Templates,无法生成与其他代码在同一行上运行的代码。希望在contact.save()行出现的第三个if语句的下面一行。请参考原始块。谢谢你的帮助 if request.POST.get('program'): savevalue = Contact() savevalue.program=request.POST.get('program') savevalue.save() 原始块 def index(request):

无法生成与其他代码在同一行上运行的代码。希望在contact.save()行出现的第三个if语句的下面一行。请参考原始块。谢谢你的帮助

if request.POST.get('program'):
            savevalue = Contact()
            savevalue.program=request.POST.get('program')
            savevalue.save() 
原始块

def index(request):
    if request.method == 'POST':
        name = request.POST.get('name', '')
        contact = request.POST.get('contact', '')
        address = request.POST.get('address', '')
        # program2 = request.POST.get('program2', '')
        # bba = request.POST.get('bba', '')
        # bhm = request.POST.get('bhm', '')
        email = request.POST.get('email', '')
        w3review = request.POST.get('w3review', '')
        if request.POST.get('program'):
            savevalue = Contact()
            savevalue.program=request.POST.get('program')
            savevalue.save()

        if name and contact and address and email and w3review:
            contact = Contact(name=name, contact=contact, address=address, email=email, w3review=w3review)
            contact.save()
        else:
            return HttpResponse("Enter all details")
        
    return render(request, 'index.html')