from http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index ....
------------------------------------------------- Using a form in a view The standard pattern for processing a form in a view looks like this: def contact(request): if request.method == 'POST': # If the form has been submitted... form = ContactForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... return HttpResponseRedirect('/thanks/') # Redirect after POST else: form = ContactForm() # An unbound form return render_to_response('contact.html', { 'form': form, }) -------------------------------------------------- I don't understand where is the difference... Alfredo 2008/10/14 Steve Holden <[EMAIL PROTECTED]>: > > Alfredo Alessandrini wrote: >> I've setup a form from a model: >> >> class PlayerForm(ModelForm): >> class Meta: >> model = Player >> >> I've setup a view function for save the data inserted in the form: >> >> def setup_player(request): >> if request.method == 'POST': >> form = PlayerForm(request.POST) >> if form.is_valid(): >> form.save() >> return HttpResponseRedirect(form_successfully) >> else: >> form = PlayerForm() >> return render_to_response('player_form.html', {'form': form}) >> >> But I've this error: >> >> ValueError: The view mysite.views.setup_player didn't return an >> HttpResponse object. >> >> why?? >> > Because you have no action when request.method != "POST", and so the > view is returning None. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---