On Sat, Jun 14, 2008 at 7:36 PM, LB <[EMAIL PROTECTED]> wrote:
>
> Thanks,
>
> Another question :
>
> why does
> anniv = Contact.objects.filter(naissance__month=5)
> works
>
> and
> anniv = Contact.objects.filter(naissance__month__gt=5)
> raise this exception :
> <class 'django.core.exceptions.FieldError'>: Join on field 'naissance'
> not permitted.

A similar reason to the last error - in this case, __month__gt is not
a valid query operator.

When Django looks at a query term, it breaks apart the term into
parts, separated by double underscores. It compares the last part to a
list of known operators (gt, lt, etc); if it finds a match, it assumes
the query term is using that operator. If it can't find a match, it
assumes that the operator is 'eq'.

Django removes the operator portion from the query term, and takes the
remaining parts; each remaining double underscore is interpreted as a
join on a related table.

So - what you were trying to do was combine the `month` and `gt`
operators - you can't do that. Django interpreted your query as 'join
the Contact with the naissance table, and check that the month
attribute is greater than 5'. Obviously, this doens't work because
naissance isn't a table - it's a date field on the Contact model.
Instead, you need to find a single operator that will do what you
want. Without knowing exactly what you want to do, I'm guessing that
__range is probably the best option.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to