here´s my view (I think the form-class is not so important for my question):
if request.method == 'POST': form = UserProfileForm(request.POST) if form.is_valid(): # SAVING user_profile.sex = form.cleaned_data['sex'] user_profile.date_of_birth = form.cleaned_data ['date_of_birth'] user_profile.phone_number = form.cleaned_data ['phone_number'] user_profile.place_address = form.cleaned_data ['place_address'] user_profile.place_zip_code = form.cleaned_data ['place_zip_code'] user_profile.place_location = form.cleaned_data ['place_location'] if form.cleaned_data['place_state']: user_profile.place_state_id = int(form.cleaned_data ['place_state']) else: user_profile.place_state_id = "" user_profile.save() user_data.first_name = form.cleaned_data['first_name'] user_data.last_name = form.cleaned_data['last_name'] user_data.save() else: # INITIAL_DATA initial_data = {'sex': user_profile.sex, 'first_name': user_data.first_name, 'last_name': user_data.last_name, 'date_of_birth': user_profile.date_of_birth, 'phone_number': user_profile.phone_number, 'place_address': user_profile.place_address, 'place_zip_code': user_profile.place_zip_code, 'place_location': user_profile.place_location, 'place_state': user_profile.get_state_id, } form = UserProfileForm(initial=initial_data) problem is: I´d like to clean this view by eliminating SAVING and INITIAL_DATA, so the view should look like this (if that´s possible): if request.method == 'POST': form = UserProfileForm(request.POST) if form.is_valid(): # SAVING do_save() else: # INITIAL_DATA get_initial_data() form = UserProfileForm(initial=initial_data) question is: where to define do_save() and get_initial_data()? do I have to define that in my model and call something like: user_profile.save() or user_profile.get_initial_data()? or can I define these functions within the form? what´s the "right way" to do that? I´ve done some research but all I could find were examples for form_for_model and form_for_instance, which is not what I need. If someone knows a more complex example of using newforms ... please share it. thanks, patrick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---