Thanks Karen, I must have gotten it just as you posted your reply, Thanks anyhow, ~Simon
On Sep 23, 2:59 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Tue, Sep 23, 2008 at 5:47 PM, Simon Forman <[EMAIL PROTECTED]> wrote: > > > I'm getting an error I can't figure out. > > > I have a "UserProfile" class that is the AUTH_PROFILE_MODULE setting, > > but then when I am trying to create an object from a model class that > > has a ForeignKey for that UserProfile class > > > char = Character( > > user_profile = request.user.profile, > > ... > > > where > > > class Character(Model): > > user_profile = ForeignKey(UserProfile, related_name='characters') > > ... > > > I get a ValueError: > > > Cannot assign "<django.db.models.fields.related.RelatedManager object > > at 0x552b9a0b10>": "Character.user_profile" must be a "UserProfile" > > instance. > > > The user is logged in, and has a UserProfile according to the admin > > interface. > > Apparently request.user.profile is a RelatedManager type thing, not an > instance of your user profile. Per the docs > (http://www.djangoproject.com/documentation/authentication/#storing-ad...) > it appears you should be using the get_profile() method on a User instance > to retrieve the user's profile, so I'd try: > > char = Character( > user_profile = request.user.get_profile(), > ... > > instead of what you have. > > Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---