bcrem
unread,Mar 26, 2012, 9:15:04 PM3/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello Django Nerds!
So I have a (somewhat) complicated lookup I'm trying to do; here's the
gist of it:
1. I have a Store class, with a User ManyToManyField, Store.users
2. I have a user profile class associated with each user,
UserProfile, accessible through the usual User.get_profile()
3. UserProfile has a status variable, UserProfile.status, which can
be 'Active', 'Inactive', or 'Deleted'
I'm trying to display a list of users for a particular store;
currently I generate this list using the following line:
userList = request.session['currentStore'].users.all()
Works great; however, now I'd like to filter out all users with a
status of 'Deleted'. Now, if status were a User attribute, I could
just try this:
userList =
request.session['currentStore'].users.exclude(status=='Deleted')
or something similar.
THE PROBLEM: How do I generate this no-deleted-users list for the
given store, using the ManyToManyField Store.users, but based on the
store.users UserProfile.status? I know there's some kinky django
black magic reverse-lookup way to do it in a single magnificent
line...just haven't a clue what it might be. Ideas?
First person with the right answer: thank you - please treat yourself
to a donut...