Sorry - it should read: b = Book.objects.get(id=1) #new book request.user.get_profile().shelf1.add(b) #add book to shelf1 request.user.get_profile().shelf1.remove(b) #remove from shelf1 request.user.get_profile().shelf2.add(b) #add to shelf2
I think something like this works: Class Book #details Class Shelf1 user = foreignkey(UserProfile) book = foreignkey(related_name ="shelf1") Class Shelf2 user = foreignkey(UserProfile) book = foreignkey(related_name="shelf2") Class UserProfile user = foreignkey(User, unique = True) but it doesn't look very nice... I'd prefer to find a way to do something like this: b = Book.objects.get(id=1) #new book request.user.get_profile().shelf.1.add(b) #add book to shelf1 request.user.get_profile().shelf.1.remove(b) #remove from shelf1 request.user.get_profile().shelf.2.add(b) #add to shelf2 -- 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=.