> b = Book.objects.get(id=1)  #new book
> request.user.get_profile().shelf1.add(b)  #add book to shelf1
> request.user.shelf1.remove(b)     #remove from shelf1
> request.user.shelf2.add(b)      #add to shelf2

Looks like you're trying to add the foreignkey to the User model
instead of the UserProfile model. If you go:

request.user.userprofile_set.add(b)

You should have the object added. You can confirm that the userprofile
model is associated with the User model in the python shell using the
command dir(User) after you've imported the User model. You should see
'userprofile_set'. Or you could user:

p = request.user.get_profile()
p.shelf1.add(b)

R.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.


Reply via email to