On Sat, Jun 14, 2008 at 6:56 PM, LB <[EMAIL PROTECTED]> wrote: > > 1 ) how to get all contacts with a known birthday ? I tried : > > m = Contact.objects.filter(naissance__is_null=False) > but I got the following exception : > <class 'django.core.exceptions.FieldError'>: Join on field 'naissance' > not permitted.
You are close - but with a minor typo. You have an extra underscore in the isnull. What you need is: >>> Contact.objects.filter(naissance__isnull=False) The error you are seeing is caused because Django doesn't know what is_null means, so it assumes it's a field on a related model - but it isn't, so you get a 'join not permmitted' error. > 2 ) I would like to make a view presenting the anniversaries of the > next 30 days. > I haven't found in the do how to elaborate complexes queries and how > to combine conditions with an "OR" > Can you points me some documentation on this ? http://www.djangoproject.com/documentation/models/or_lookups/ > So finally, I've thought to the following code : > > import datetime > today = datetime.datetime.today() > datelim = today + datetime.timedelta(30) > > anniv = Contact.objects.filter( > naissance__is_null=False, naissance__month__range=(today.month, > datelim.month) ).exclude( > naissance__month=today.month, > naissance__day__lt=today.day).exclude( > naissance__month=datelim.month, naissance__day__gt=datelim.day) > > But I have the same error that before : > <class 'django.core.exceptions.FieldError'>: Join on field 'naissance' > not permitted. As before - an extra underscore. 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 -~----------~----~----~----~------~----~------~--~---