I'm new to Django and a relatively inexperienced programmer. I've
started working with the new forms and have been able to take user
input, validate it and write it to the table. Really slick and with
minimal code. Great.

I now want to take an existing user record and create an edit account
form, where the data entered by the user in the registration form is
represented and available to edit. Seemed simple when I set out to do
it, but I can't seem to populate the form.

Should I define which data goes into the form fields using the
'initial' data in the Form definition? If so, how would I do this,
because I don't know the user_id and can't place a -
userid=request.user.id request in this definition.

This would suggest that I do the form population in the view
definition. At the moment it looks like this:

     if not request.user.is_authenticated():
            return HttpResponseRedirect("/userlogin/")
        else:
            if request.method == 'POST':
                form=UserAccountForm(request.POST)
                if form.is_valid():
                    user_nm= form.clean_data['username']
                    # rest of form input and code validation
                    return render_to_response('account.html',
{''form':form})
                else:
                    form=UserAccountForm()
            return render_to_response('account.html',{'form':form})

However, all of the fields are empty (not surprisingly because I've
not linked with the data)
Can anyone give me a bit of guidance on populating the form from the
table?

Thanks


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to