Пример #1
0
def edit_disease(request,pk):
    try:
        disease=Disease1.objects.get(id=pk)
    except:
        return redirect('disease')        
    assign_disease_form=AddDiseaseForm(request.POST,instance=disease)
    mydict={'assign_disease_form':assign_disease_form,'disease':disease}
    if request.method=='POST':
        assign_disease_form=AddDiseaseForm(request.POST,instance=disease)
        if assign_disease_form.is_valid():
            assign_disease_form.save()
            return redirect('disease')
    return render(request,'roleadmin/assign_disease_edit_form.html',context=mydict)
Пример #2
0
def assign_disease(request):
    if request.method == "POST":
        assign_disease_form = AddDiseaseForm(request.POST or None)
        if assign_disease_form.is_valid():
            assign_disease_form.save()
            return redirect('disease')
        else:
            context = {'assign_disease_form': assign_disease_form}
            return render(request, 'roleadmin/assign_disease_form.html',
                          context)
    else:
        assign_disease_form = AddDiseaseForm()
        context = {'assign_disease_form': assign_disease_form}
        return render(request, 'roleadmin/assign_disease_form.html', context)