Created
October 14, 2011 10:45
-
-
Save infyloop/1286797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem Statement: | |
a user belongs to one/many user_groups and one/many user_types | |
a channel belongs to one/many user_groups and one/many user_types | |
a video belongs to one/many channels | |
when a user logs in, he should be showed video from the channel which matches his user_group and user_type. | |
Solution done in django shell: | |
uobj = UserProfile.objects.get(user__username = "**") | |
ug = uobj.belongs_to_user_group | |
ut = uobj.belongs_to_user_type.all() | |
Video.objects.filter(belongs_to_channel__belongs_to_group__in=ug, belongs_to_channel__available_to_user_type__in = ut).distinct() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment