Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 22, 2005 14:58:26

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ManyToMany problems


Hi,

Based on the following model

from django.models.auth import User

class PolicyCategory(meta.Model):
name = meta.CharField(maxlength=100);
users = meta.ManyToManyField(User, blank=True)

class META:
db_table = 'intranet_policies'
module_name = 'policies'
verbose_name_plural = 'policies'

i'm trying to get list of users with field lookups

>>> from django.models.auth import users
>>> from django.models.intranet import policycategories
>>>
>>> pc = policycategories.get_object(pk=1)
>>> pc.get_user_list(groups__name__exact='Tech')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
return args(*(args+moreargs), **dict(kwargs.items() +
morekwargs.items()))
TypeError: method_get_many_to_many() got an unexpected keyword argument
'groups__name__exact'

Seems like get_xxx_list in many to many relations doesn't support
lookups ? Or is this a bug ? Cos if i do the following

>>> u = users.get_object(pk=1)
>>> u.get_intranet_policycategory_list(name__exact='Billing')


everything is working fine. Any hints on this, maybe i'm missing
something ?

Offline

#2 Nov. 22, 2005 16:44:31

Adrian H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ManyToMany problems


On 11/22/05, plisk <> wrote:
> >>> pc.get_user_list(groups__name__exact='Tech')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
> line 3, in _curried
> return args(*(args+moreargs), **dict(kwargs.items() +
> morekwargs.items()))
> TypeError: method_get_many_to_many() got an unexpected keyword argument
> 'groups__name__exact'
>
> Seems like get_xxx_list in many to many relations doesn't support
> lookups ? Or is this a bug ?

Does the following work?

"""
from django.models.auth import users
users.get_list(groups__name__exact='Tech')
"""

Behind the scenes, pc.get_user_list() is just a wrapper around
users.get_list(). So a good way to test things in this case is to use
users.get_list(). If the parameters aren't valid there, they won't be
valid in pc.get_user_list().

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Offline

#3 Nov. 22, 2005 17:02:25

r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

ManyToMany problems


Adrian Holovaty wrote:On 11/22/05, plisk <> wrote:pc.get_user_list(groups__name__exact='Tech')Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
return args(*(args+moreargs), **dict(kwargs.items() +
morekwargs.items()))
TypeError: method_get_many_to_many() got an unexpected keyword argument
'groups__name__exact'

Seems like get_xxx_list in many to many relations doesn't support
lookups ? Or is this a bug ?Does the following work?

"""
from django.models.auth import users
users.get_list(groups__name__exact='Tech')
"""Yes, this one works fine. And just pc.get_user_list() also works, butwith arguments it fails. Tried plainpc.get_user_list(username__exact='admin') and got the same error. By theway, rev 1350.Behind the scenes, pc.get_user_list() is just a wrapper around
users.get_list(). So a good way to test things in this case is to use
users.get_list(). If the parameters aren't valid there, they won't be
valid in pc.get_user_list().In users.get_list() everything works as it should..

plisk

Offline

Board footer

Moderator control

Enjoy the 27th of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support