thank you very much .. how is the template for such a view ... I've put each 
form in a form tag like that

<fieldset>
               
            <fieldset>             
                <legend>EMETTEUR</legend>
                    <form action=" " method="post">  {% csrf_token %}
                        {{ emet_form.as_p }}
                        <input type="reset" value="effacer" />  
                   </form>
               </fieldset>

            
            <fieldset>             
                <legend>DESTINATAIRE</legend>
                    <form  action=" " method="post">  {% csrf_token %}
                        {{ des_form.as_p }}
                        <input type="reset" value="effacer" />  
                   </form>
               </fieldset>

       
           <fieldset>             
                <legend>FICHIER</legend>
                    <form  action=" " method="post">  {% csrf_token %}
                        {{ fich_form.as_p }}
                        <input type="reset" value="effacer" />  
                   </form>
               </fieldset>

              
                    <form  action="{%url 'formulaire.views.enregister'%}" 
method="post">  {% csrf_token %}
                     <input type="submit" value="enregistrer" />  
                   </form>
           


</fieldset>











On Tuesday, July 29, 2014 7:34:16 PM UTC, C. Kirby wrote:
>
>
>
> They are not getting validated, or validation is failing?
> Also, it looks like you are using model forms. You can get rid of all the 
> for,.cleaned_data.get lines and just use:
>
> if emet_form.is_valid() and des_form.is_valid() and fich_form.is_valid(): 
>       emet = emet_form.save()
>       des = des_form.save()
>       fich = fich_form.save()
>
>
> On Tuesday, July 29, 2014 10:53:59 AM UTC-5, Devin Cky wrote:
>>
>>
>>
>> On Tuesday, July 29, 2014 1:48:00 PM UTC, Tom Evans wrote:
>>>
>>> On Tue, Jul 29, 2014 at 12:31 PM, Devin Cky <vin1...@gmail.com> wrote: 
>>> > hi i am a beginner in django and I have a problem .. how can I 
>>> validate 3 
>>> > forms on the same page simultaneously ..please help me 
>>> > 
>>>
>>> If they are different types of forms, you cannot use a formset. 
>>>
>>> In that case, just test whether all forms are valid. If they are all 
>>> valid, save/process the forms. If not, re-render the page with the 
>>> bound forms and display the errors. 
>>>
>>> Eg 
>>>
>>> def myview(request): 
>>>   if request.method == 'POST': 
>>>     form_a = FormA(request.POST) 
>>>     form_b = FormB(request.POST) 
>>>     form_c = FormC(request.POST) 
>>>     if form_a.is_valid() and form_b.is_valid() and form_c.is_valid(): 
>>>       form_a.save() 
>>>       .... 
>>>       return HttpResponseRedirect(...) 
>>>   else: 
>>>     form_a = FormA() 
>>>     form_b = FormB() 
>>>     form_c = FormC() 
>>>   return render(...) 
>>>
>>> Cheers 
>>>
>>> Tom 
>>>
>>
>>
>>
>>
>>
>> -------thank you TOM--- 
>>   when I submit my forms .. no field is validated
>>
>>
>> .......view.....
>>
>>
>>
>> def enregistrer(request):
>>         if request.method == 'POST': 
>>             emet_form = EmetteurForm(request.POST, prefix = "emet")
>>             des_form = DestinataireForm(request.POST, prefix = "des")
>>             fich_form = FichierForm(request.POST, prefix = "fich")
>>             if emet_form.is_valid() and des_form.is_valid() and 
>> fich_form.is_valid(): 
>>                     civilite = emet_form.cleaned_data.get('civilite')
>>                     nom = emet_form.cleaned_data.get('nom')
>>                     prenom = emet_form.cleaned_data.get('prenom')        
>>         
>>                     cni = emet_form.cleaned_data.get('cni')
>>                     mail = emet_form.cleaned_data.get('mail')
>>                     telephone = 
>> emet_form.cleaned_data.get('telephone')    
>>                     pays = emet_form.cleaned_data.get('pays')
>>                     ville = emet_form.cleaned_data.get('ville')
>>                     quartier = emet_form.cleaned_data.get('quartier')
>>                     emet = emet_form.save()
>>                     nom = des_form.cleaned_data.get('nom')
>>                     prenom = des_form.cleaned_data.get('prenom')
>>                     mail = des_form.cleaned_data.get('mail')  
>>                     telephone = des_form.cleaned_data.get('telephone')
>>                     des = des_form.save()
>>                     description_fichier = 
>> fich_form.cleaned_data.get('description_fichier')
>>                     date_enregistrement = 
>> fich_form.cleaned_data.get('date_enregistrement')
>>                     observation = 
>> fich_form.cleaned_data.get('observation')
>>                     montant_prestation = 
>> fich_form.cleaned_data.get('montant_prestation')    
>>                     fich = fich_form.save()
>>         else:
>>             emet_form = EmetteurForm()
>>             des_form = DestinataireForm()
>>             fich_form = FichierForm() 
>>                     
>>     return 
>> render(request,'formulaire/information.html',locals())            
>> //***please look ..if my view is good***//
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f98026b1-a5fd-46d6-87da-eb9f0cc5dc44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to