Ok great.

Take care.

On Mon, Aug 15, 2016 at 3:10 AM, Nestor Burma <nesto...@caramail.fr> wrote:

> Oh I just have found the trick !
> It comes from a django bug in some earlier version of django 1.9. in
> FormeMixinBase.form_invalid()
>
> I had:
>     def form_invalid(self, form):
>         return self.render_to_response(self.get_context_data())
>
> in place of:
>     def form_invalid(self, form):
>         return self.render_to_response(self.get_context_data(form=form))
>
> so parameters wasn't transfered. Probably my pip did'nt install last
> version, and my production version was not exactly the same as my
> development one... An upgrade solved the problem.
>
> Ouf ! I believed I was going to come crazy !
>
> Thank's for your answer.
>
> *Envoyé:* lundi 15 août 2016 à 08:59
> *De:* "M Hashmi" <mhashmi1...@gmail.com>
> *À:* django-users@googlegroups.com
> *Objet:* Re: Strange bug with form errors
> Can you paste the full traceback from production server?
>
> On Sun, Aug 14, 2016 at 11:53 PM, Nestor Burma <nesto...@caramail.fr>
> wrote:
>>
>> I have a very strange bug with fom errors. *On my development site, my
>> code works fine*. But on my production site (apache + mod-wgsi +
>> posgresql), the form errors I defined in is_valid() method of my ModelForm
>> (in a generic CreateView) are not product by the template. Have you already
>> seen such a thing ?
>>
>> Here is my code :
>>
>>
>> *views.py:*
>> class UserCreate(CreateView):
>>     model = User
>>     template_name = 'base/userCreate.html'
>>     success_url = '/utilisateurs/nouveau/success/{id}'
>>     form_class = UtilisateurCreateForm
>>
>> *forms.py:*
>> class UtilisateurCreateForm(forms.ModelForm):
>>     class Meta:
>>         model = User
>>         fields = ['first_name', 'last_name', 'email']
>>     def is_valid(self):
>>         valid =  super().is_valid()
>>         if email != '' and User.objects.filter(email = email).exists():
>>             self.add_error('email', 'Il existe déjà un utilisateur avec
>> cet email.')
>>             valid = False
>>         return valid
>>
>> *userCreate.html:*
>> {% extends "base/base.html" %}
>> {% block contenu %}
>> <h3>Nouvel utilisateur :</h3>
>> <form action="" method="post">{% csrf_token %}
>>     {{ form.as_p }}
>>     <input type="submit" value="Enregistrer" />
>> </form>
>> {% endblock %}
>>
>> Thank's for your help.
>>
>>
>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/trinity-68cd841e-22eb-421b-95ea-
>> 2b94ca00a28b-1471243983623%403capp-mailcom-bs11
>> <https://groups.google.com/d/msgid/django-users/trinity-68cd841e-22eb-421b-95ea-2b94ca00a28b-1471243983623%403capp-mailcom-bs11?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CANoUts4VJ61snPG3M%3DNHKn5mhfnQ8G_
> FOZNs3XeYoV8yhmJc0Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANoUts4VJ61snPG3M%3DNHKn5mhfnQ8G_FOZNs3XeYoV8yhmJc0Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/trinity-8a769b2c-ae6e-412e-9a23-
> 0d8a855897ce-1471255851081%403capp-mailcom-bs11
> <https://groups.google.com/d/msgid/django-users/trinity-8a769b2c-ae6e-412e-9a23-0d8a855897ce-1471255851081%403capp-mailcom-bs11?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts6PK8oOj6fUT2Y_oC206Zc_HYGqub9jKhZic8k0xS818w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to