Hi
Newbie trying to preset a field on a form where the object is to be
inserted. The snippet below does not do it.
class FooForm(ModelForm):
class Meta:
model = Foo
<do the def stuff here>
if request.method == 'GET':
if foo_id > '0':
foo=Foo.objects.get(pk=foo_id)
form = FooForm(instance=foo) # this part
works OK
else:
form = FooForm()
foo=form.save(commit=False)
foo.date = request.session['date'] # we know
request.session
['date'] has a value
form = FooForm(instance=foo)
What is a better way? TIA
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---