This is what I'm currently runnign with now...
user_list = Access.objects.filter(team =
team_profile).exclude(status = "NON")
roster = user_list.extra(
select={
'first_name': 'SELECT first_name FROM Personal
WHERE user = user_list.user'
}
)
Although I get the following error return to me:
ProgrammingError: ERROR: relation "personal" does not exist
SELECT
"login_access"."id","login_access"."team_id","login_access"."status","login_access"."user_id",
(SELECT first_name FROM Personal WHERE user=user_list.user) AS
"first_name" FROM "login_access" WHERE ("login_access"."team_id" = 2
AND (NOT ("login_access"."status" = 'NON')))
On May 20, 2:43 pm, Roboto <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I've got some issues writing this query out, so maybe I can get some
> help
> I have 4 tables:
> User (default from django)
> Profile (foreign key is User)
> Access (foreign Key is User and Team)
> Team
>
> I want make a roster for each team, so I would do the following
> "select * from access where team = team.id and access lvl = xxx)
> This would return a list of users that belong to a team and have the
> correct access level to see team (incase they've previously left the
> team.. etc)
>
> But I'd like to grab all the profiles that are associated with those
> user names that I just selected
> so it would be a (select * from profiles join (select * from access
> where team=team.id and access lvl =xxx))
>
> Is there an easy way to do this??
>
> I've gotten to roster = Access.objects.filter(team =
> team_profile).exclude(status = "NON", status = "WAT")
> to grab my user list... but to grab the associated profiles with that
> user list I'm stuck on...
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---