Just refer to the field name, you don't need the class:

prev = self.bbb_set.filter(date__lt=date)

Take a look to field lookup rules:
http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups-intro

Excerpts from serek's message of Wed Feb 16 20:51:05 -0200 2011:
> Hi
> 
> I have not idea how to describe my problem, so I show pice of code:
> 
> 
> class Aaa(models.Model):
>     name = models.CharField(max_length=200, unique=True)
>     is_active = models.BooleanField()
> 
>     class Meta:
>         ordering = ('name',)
> 
>     def doMagic(self):
>     date = '2010-05-04'
>     //here I need to take 10 conencted Bbb objects whcich data is less
> then date
>         previous10days = self.bbb_set.filter(Bbb.date <
> date).order_by('data')
> 
> 
> class Bbb(models.Model):
>     date = models.DateField()
>     value = models.DecimalField(max_digits=7, decimal_places=2)
>     aaa = models.ForeignKey(Aaa)
> 
> a = Aaa()
> a.doMagic throw error that Bbb.date is undefined - what can be wrong?
> 
-- 
Matías Aguirre <matiasagui...@gmail.com>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to