Monday, October 11, 2010

Re: Custom validation in model formset

try this...

from django.forms import ValidationError

...
for form in self.forms:
...
raise ValidationError('whatever')

On Oct 11, 1:32 pm, Duane Hilton <dua...@gmail.com> wrote:
> Changing forms to form brings a new error:
>
> *Exception Value: 'CandidateFeedForm' object has no attribute
> 'ValidationError'*
>
> Below is the view that is using the BaseCandFormSet code that I included in
> the original message. Maybe something is wrong in it? Thanks in advance for
> your suggestions. I've spent a few days using the documentation and trying
> to get this to work. I really appreciate the help. ...
>
> *def state_office(request):
>     CandFormSet = modelformset_factory(CandidateFeed,
> **queryset=CandidateFeed.objects.all().order_by('last_name',
> 'county'),** formset=BaseCandFormSet, extra=0)
>     if request.method == 'POST':
>         formset = CandFormSet(request.POST, request.FILES)
>         if formset.is_valid():
>             formset.save()
>             return HttpResponseRedirect('/foo/bar/')
>     else:
>         formset =
> CandFormSet(queryset=CandidateFeed.objects.all().order_by('last_name',
> 'county'))
>     return render_to_response('state_office.html', { 'formset': formset })*

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate