Re: form_invalid

2017-01-30 Thread Daniel Roseman
This is bad advice. You should almost never need to override the get or post methods on a class based view; there are always more specific methods to use. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group

Re: form_invalid

2017-01-30 Thread Roberto Russi
Is just what i pictured. But when form_invalid is called? Il giorno lunedì 30 gennaio 2017 02:35:54 UTC+1, Melvyn Sopacua ha scritto: > > On Sunday 29 January 2017 04:10:20 Roberto Russi wrote: > > > I need get data from a form when submit is clicked even if data are > >

Re: form_invalid

2017-01-29 Thread Norberto Bensa
t; >> https://ccbv.co.uk is your friend with class based views. >>> >> >>> >> I'd override post(self, request, *args, **kwargs), in request.POST, >>> >> you'll have your form's data (before it's validated). >>> >> >>>

Re: form_invalid

2017-01-29 Thread Norberto Bensa
t, *args, **kwargs), in request.POST, >> >> you'll have your form's data (before it's validated). >> >> >> >> HTH, >> >> Norberto >> >> >> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi <robrus...@gmail.com>: >> >&

Re: form_invalid

2017-01-29 Thread Melvyn Sopacua
On Sunday 29 January 2017 04:10:20 Roberto Russi wrote: > I need get data from a form when submit is clicked even if data are > invalid, inconplete or empty. > I try to override form_invalid in CreateView but it is never called > and form_valid, obviously, only if data are

Re: form_invalid

2017-01-29 Thread Roberto Russi
t; >> HTH, > >> Norberto > >> > >> 2017-01-29 9:10 GMT-03:00 Roberto Russi <robrus...@gmail.com>: > >>> > >>> I need get data from a form when submit is clicked even if data are > invalid, inconplete or empty. > &

Re: form_invalid

2017-01-29 Thread Norberto Bensa
gt;> have your form's data (before it's validated). >> >> HTH, >> Norberto >> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi <robrus...@gmail.com>: >>> >>> I need get data from a form when submit is clicked even if data are >>> invalid, inconplete

Re: form_invalid

2017-01-29 Thread Roberto Russi
a are >> invalid, inconplete or empty. >> I try to override form_invalid in CreateView but it is never called and >> form_valid, obviously, only if data are valid. >> Why form_invalid is never called? >> >> I have this test project with django 1.10.5

Re: form_invalid

2017-01-29 Thread Norberto Bensa
form when submit is clicked even if data are > invalid, inconplete or empty. > I try to override form_invalid in CreateView but it is never called and > form_valid, obviously, only if data are valid. > Why form_invalid is never called? > > I have this test project with d

form_invalid

2017-01-29 Thread Roberto Russi
I need get data from a form when submit is clicked even if data are invalid, inconplete or empty. I try to override form_invalid in CreateView but it is never called and form_valid, obviously, only if data are valid. Why form_invalid is never called? I have this test project with django 1.10.5

Re: form_invalid and missing ob

2015-05-14 Thread David
Fixed. Was missing: self.form = self.get_form(self.form_class) self.object_list = self.get_queryset() from def form_invalid(self, form): -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiv

Re: form_invalid and missing ob

2015-05-14 Thread David
Doh, fixed. Fix below for anyone else with the same problem: def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): return self.form_valid(form) else: return self.form_invalid(form, *args, **kwargs) def form_invalid(self, form, *args, **kwargs): messages.error

form_invalid and missing ob

2015-05-14 Thread David
']).pk data.save() messages.success(self.request, '{0} added.'.format(self.model.__name__)) if self.request.is_ajax(): return JsonResponse({'reset': True}) return super(ShowForumPostsView, self).form_valid(form) def form_invalid(self, form): messages.error(self.request, '{0} could not be saved

Re: form_invalid redirection with CBVs

2015-04-27 Thread David
Got this working. See below: class CreateComment(MultipleObjectMixin, FormView): template_name = 'comment/comment_list.html' form_class = CommentForm model = Comment paginate_by = 5 def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseForbidden()

Re: form_invalid redirection with CBVs

2015-04-24 Thread David
This is what I am working from btw: https://docs.djangoproject.com/en/1.8/topics/class-based-views/mixins/#an-alternative-better-solution -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

form_invalid redirection with CBVs

2015-04-24 Thread David
Following a form_invalid I need to redirect to the CreateComment view below with the errors shown in the form. Is this possible please? Highlighted is where I need help. Thank you for any assistance. class Comments(View): def get(self, request, *args, **kwargs): view = CreateComment.as_view