> > Entry.objects.filter(id__in=[1, 3, 4])
>
> > ...couldn't id=[] overload if the target is a list?
>
> I suppose it could if it were written that way, but it isn't. The filter
> form "filter(<field>=<value>)" is shorthand for the form
> "filter(<field>__exact=<value>)". To my knowledge, no one has written an
> operator overload
Sorry, I didn't say "operator overload" (which are either spot-on or
sophomoric, when they work).
I just meant Entry.objects.filter(id = [1, 3, 4]).
Because, IIRC, no SQL database can store arrays ('list's) in fields,
the =[] event is free to be "overloaded" by its type.
So id=[] would resolve to id__in=[], id=Scalar to id__exact=Scalar,
and the explicit versions are available if you suspect that
overloading is fragile.
(I also disagree with leaving out the spaces around =, but obviously
obeying a team style guide supersedes improving it...)
--
Phlip
--
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.