get_list() with foreignkey-parameters

0 views
Skip to first unread message

patrick kranzlmüller

unread,
Dec 19, 2005, 11:03:21 AM12/19/05
to django...@googlegroups.com
first issue:

this works fine:
milestone_list = milestones.get_list(id__exact=3, order_by=['-id'])

this doesn´t:
milestone_list = milestones.get_list(responsible__exact=1,
order_by=['-id'])

the model looks like;
responsible = meta.ForeignKey(auth.User)


second issue:

i´m now able to display the username with my app. still, i´d like to
have something like
milestone_list = milestones.get_list(responsible__exact=user.id,
order_by=['-id'])

i don´t know if this is correct for "responsible__exact" is obviously
wrong.

thanks in advance.
patrick

Adrian Holovaty

unread,
Dec 19, 2005, 11:07:49 AM12/19/05
to django...@googlegroups.com
On 12/19/05, patrick kranzlmüller <pat...@vonautomatisch.at> wrote:
> this works fine:
> milestone_list = milestones.get_list(id__exact=3, order_by=['-id'])
>
> this doesn´t:
> milestone_list = milestones.get_list(responsible__exact=1,
> order_by=['-id'])
>
> the model looks like;
> responsible = meta.ForeignKey(auth.User)

Try this:

milestone_list = milestones.get_list(responsible__id__exact=1)

You can also do something like this:

milestone_list = milestones.get_list(responsible__username__exact='patrick')

Adrian

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

Andreas Stuhlmüller

unread,
Dec 19, 2005, 11:21:00 AM12/19/05
to django...@googlegroups.com
Hi Patrick,

> this doesn´t:
> milestone_list = milestones.get_list(responsible__exact=1,
> order_by=['-id'])

Try this:
milestone_list = milestones.get_list(responsible__id__exact=1,
order_by=['-id'])

"1" is the user's id, so this should work:

milestone_list = milestones.get_list(responsible__id__exact=user.id,
order_by=['-id'])

Cheers,
Andreas


On 12/19/05, patrick kranzlmüller <pat...@vonautomatisch.at> wrote:
>

Grigory Fateyev

unread,
Dec 19, 2005, 11:26:23 AM12/19/05
to django...@googlegroups.com
Hello patrick kranzlm_ller!

On Mon, 19 Dec 2005 17:03:21 +0100 you wrote:

>
> first issue:
>
> this works fine:
> milestone_list = milestones.get_list(id__exact=3, order_by=['-id'])
>

> this doesn_t:
v> milestone_list = milestones.get_list(responsible__exact=1,
> order_by=['-id'])

milestone_list = milestones.get_list(responsible__id__exact=1,
order_by=['-id'])

> the model looks like;
> responsible = meta.ForeignKey(auth.User)
>


--
Всего наилучшего!
greg [at] anastasia [dot] ru Григорий.

patrick kranzlmüller

unread,
Dec 19, 2005, 11:34:48 AM12/19/05
to django...@googlegroups.com
thanks.

i then used
milestone_list =
milestones.get_list(responsible__id__exact=request.user.id)
to display the milestones for the logged-in user.

seems to work.

Reply all
Reply to author
Forward
0 new messages