Hi,

I'm new to django and also new to databases. I'm trying to make a
simple contact editor.
So I created the following model :

class Contact(models.Model):
    nom_famille = models.CharField("nom de famille", max_length=30)
# french for last name
    prenom      = models.CharField("prénom",
max_length=30)                   # french for first name
    [ ...]
    naissance   = models.DateField(null=True,
blank=True)                         # french for birthday


I've filled the created database with some vacrd, and now I'm stuck
with some database problems :

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.

what does that mean ?

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 ?

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.

any clue ?

--~--~---------~--~----~------------~-------~--~----~
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