Dear djangonauts,
I'm playing with formfields and manipulators: wonderful! But I'm
missing one thing: following docs on Forms and Manipulators I'm not
able to put model's default values to fill forms in the proper way.
Consider the last example of "Using the AddManipulator" subsection:
------------
def create_place(request):
manipulator = places.AddManipulator()
if request.POST:
# If data was POSTed, we're trying to create a new Place.
new_data = request.POST.copy()
........(cut).........
else:
# No POST, so we want a brand new form without any data or
errors.
errors = new_data = {}
# Create the FormWrapper, template, context, response.
form = formfields.FormWrapper(manipulator, new_data, errors)
return render_to_response('places/create_form', {'form': form})
---------------
from what is written, when create_place is called with no POST data,
the "form" has new_data={}, so default values are missing (assume that
Place has some explicit default values in the model).
I'd like to use model's default values in that form, basically filling
new_data={} automagically from model's definitions. How can I do it?
Right now I'm only able to do it "by hand", like writing explicitely
new_data={'city':'NoWhere', 'zip_code':'12345'} instead of new_data={},
which is not so nice.
Thanks in advance for every ideas/suggestions to solve this problem,
Emanuele
Note: my request looks like in some way to Bryan Murdock's request
(unanswered):
http://groups.google.it/group/django-users/browse_thread/thread/e97eeed0b3256564/355a55a1ff7e4a61?q=form+default+values&rnum=1#355a55a1ff7e4a61