On 9/26/06, froke <[EMAIL PROTECTED]> wrote:
> When I submit the form, I get the following in errors
> (update_object.errors):
> 'user': ['This field is required.']

When you submit your form, you are using create_object/update_object
to create/update your UserProfile instance, based upon the form values
from the Request.

However, there is nothing in the form data that can be used to
populate UserProfile.user. While the current user _is_ stored as
request.user, the generic views don't know that they have to populate
UserProfile.user with the value of request.user. Hence the 'user' is
required message.

The easiest fix I can think of would be to put a hidden field in your
form that holds the id of the current user. This will put a 'user'
entry into your form data, which will allow the create/update generic
views to submit without error.

Another option would be to use the 'follow' argument in the
create/update generic views: this argument describes which attributes
of an object will be represented as field data; if you list the
attributes that _are_ present as fields, but exclude 'user', then the
error should go away. However, this assumes that UserProfile.user
is/will be assigned at some other time.

Yours,
Russ Magee %-)

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

Reply via email to