in the user-group, i found a posting where adrian said:
"The query parameters are, essentially, the same as keyword arguments
that can be passed to get_list(). "
can anybody give me a hint on how to accomplish that?
i tried
def milestones_overview(request, project_id):
milestones_list = milestones.get_list(request.GET)
... but that didn´t work.
thanks,
patrick
The second method is recommended because it will set myVar to None if
the GET variable is not specified.
Hope this helps.
actually, i don´t really know my query parameters.
could be responsible__id__exact=5
or status__exact=1
or responsible__id__exact=5&status__exact=5
... and so on.
so, it´d be nice to have something like milestones_list =
milestones.get_list(x), where x is the query.
thanks,
patrick
milestones_list = milestones.get_list(**request.GET) should work.
Andreas
q = []
for key, value in request.GET.items():
q.append ( "%s = %s" % (key, value) )
q = ", ".join(q)
print q
cmd = "milestones_list = milestones.get_values(%s)" % q
exec cmd
You're right. You have to consider that request.GET and request.POST
are MultiValueDicts. If you don't expect one key to have more than one
value, something like this might work:
milestones_list = milestones.get_list(
**dict([(k, v[0]) for (k, v) in request.GET.items()])
)
Andreas
patrick
UGH! Do *not* use that code.
params = dict(request.GET.items())
milestones.get_values(**params)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
patrick
Method 1:
leads.get_list(**request.GET)
Method 2:
params = dict(request.GET.items())
milestones.get_values(**params)
Method 1 works with keywords that want lists. For example.. the order
by clause works in method 1 but not in method 2. (?order_by=city)
Method 2 works with keywords that do not require a list. For example,
the limit and offset keywords work in method 2 and do not work in
method 1. (?offset=2&limit=1)
I believe this is where some confusion is setting in. Could someone
clarify how to write a url that one of these methods support.
I'd like to go on record as saying I don't like either one of them;
letting a user decide what queries you're going to run by passing in
GET parameters just gives me the willies.
--
"May the forces of evil become confused on the way to your house."
-- George Carlin