KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know is_valid() on a bounded form checks if all required data is entered. This is not what I want. I want to check if any field was filled on the form. Any ideas? Elaborating: I want to give the user the choice of not filling in the form at all. However, if they attempt to fill it in (ie: changed a value in a field from it's initial value---usually empty value), I want to validate it. The view would be something like this: def get_opinion(request): if request.method == 'POST': f = OpinionForm(request.POST) if form_is_blank(f): return HttpResponseRedirect(reverse('thank_you_anyway')) elif f.is_valid(): #Process here return HttpResponseRedirect(reverse('thanks_for_participating')) else: initial = {'weekday': date.today().strftime('%A')} f = OpinionForm(initial=initial) return render_to_response( 'get_opinion.html', {'form': f,}, RequestContext(request) ) What I want is the form_is_blank() part.
Tags (comma-separated)
Save Edits
Cancel