Hi, 

 

I'v got this piece of code:

 

def get_my_choices(gruppe):

    users = User.objects.all()

    choices_list = ()

    for user in users:

        try:

            for groupe in gruppe:

                for groupe2 in user.groups.all():

                    if groupe2 == groupe and (user.id,user) not in
choices_list and groupe2.name not in
['Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Man
ager']:

                        choices_list += ((user.id,user),)


        except:

            pass

    return choices_list

 

The parameter is the result of a user.groups.all() call. 

This function causes over db-queries and I was wondering if anyone sees
a way of optimizing that a little bit. 

I was playing around with values_list() but couldn't get it working.

 

Any ideas ?

 

regards 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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=en.

Reply via email to