On Tue, 2009-03-03 at 12:31 -0800, Tim wrote:
> I have some models setup that allows users to have an inventory of
> items: books and movies. These are setup as inherited models.
>
> What I would like to do is allow a user to select a current book and a
> current movie, but only from "valid" options in that user's inventory.
> What I mean by valid is that a user should not be able to select a
> book as their current movie, or a movie as their current book.
>
> Here is what I have so far. This works, except that it does not limit
> the user to what is in their inventory, nor does it validate that the
> current_book is actually a book.
>
> Any thoughts or ideas of how to achieve this?
Put a "type" field on the Item model to indicate what type of thing it
represents. Then, if type 1 is, say, books, you can filter using
Item.objects.filter(item_type=1)
to only get the books.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---