Thanks Rajesh, That should sort out my problem.
As a side note, it seems 'base' and 'base__inherited' appear to do the same thing: >>> print Refered.objects.get(base__inherited=b).x 1 >>> print Refered.objects.get(base__inherited=i).x 2 >>> print Refered.objects.get(base=b).x 1 >>> print Refered.objects.get(base=i).x 2 Martin On Wed, Nov 19, 2008 at 3:33 PM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > Hi Martin, > >> I have been trying to use inherited models and back references for >> filter queries, using django 1.0, 'final'. Whilst I am able to use >> back references for the base class, I can not do so for the inherited >> class (see example below). Is there any reasons why I should not be >> able to do this? > > See below... > >> >> Regards, >> Martin >> >> from django.db import models >> >> class Refered(models.Model): >> x = models.IntegerField() >> >> class Base(models.Model): >> ref = models.ForeignKey(Refered) >> >> class Inherited(Base): >> pass >> >> # Then having run manage.py syncdb: >> > r1 = Refered(x = 1) > r1.save() > r2 = Refered(x = 2) > r2.save() > b = Base(ref = r1) > b.save() > i = Inherited(ref = r2) > i.save() >> >> print Refered.objects.filter(base = b) #This line works >> print Refered.objects.filter(derived = d) #This line does not work > > That should be: > > print Refered.objects.filter(base__inherited=i) > > In other words, you can get to your inherited/derived object via the > base object that defines the ForeignKey to your refered object. > > -Rajesh D > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

