Hi. I'm quite new to Django so please excuse any ignorance. I'm trying to change the value of a ModelForm attribute and execute the same view with the altered attribute. I've read and read the ModelForms docs but I can't grasp how to do this.
In the view the POST data comes back and I populate a ModelForm with it: f = BuildForm(request.POST) I then want to alter an attribute of this object so following the docs I save it uncommitted to get back a Model object: new_build = f.save(commit=False) Then I alter the attribute using a function that just returns a string: new_build.build_path = FindPath(request.POST['build_release']) How do I now put this into a form that I render using the same template/view as I'm currently using? (I've copied the whole function below for completeness). The Model object I'm getting back from the save() method just seems to render in the template as the value of the primary key? Thanks for any help. def newbuild(request): if request.POST: if request.POST['build_path']: f = BuildForm(request.POST) f.save() return render_to_response('bmi/thanks.htm',) elif request.POST['build_release']: f = BuildForm(request.POST) new_build = f.save(commit=False) new_build.build_path = FindPath(request.POST ['build_release']) new_build.save() return render_to_response('bmi/newbuild.htm', {'request':request, 'new_build' : new_build, }) else: form = BuildForm(initial={'created_date': datetime.datetime.now ()}) return render_to_response('bmi/newbuild.htm', {'form' : form}) --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---