Is your CF base class an abstract base class[1]?  If it's not, then your
database actually has separate tables for CF, CFI and CFT .. and when you
access a `doc.cf` you're really getting the CF model instance, *not* the
derived class instance.

IIRC if you make CF an abstract base class then this will work the way you
want -- accessing doc.cf will return an instance of the appropriate derived
class.

Alternatively, if you want to keep the multi-table setup, you can try to get
each derived class instance from the base class, as described here[2] ("If
you have a Place that is also a Restaurant...") -- like:

{{{
x = doc.cf.all()[0]
try:
  x = x.cfi
  x_is_a_CFI = True
  x_is_a_CFT = False
except CFI.DoesNotExist:
  try:
    x = x.cft
    x_is_a_CFT = True
    x_is_a_CFI = False
  except CFT.DoesNotExist:
    # x is neither a CFI nor a CFT
}}}

[1]
http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes

[2]
http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance

On Fri, May 6, 2011 at 3:41 PM, pbzRPA <pbz...@gmail.com> wrote:

> Just to clarify your suggestion
>
> In [100]: isinstance(x, CFT)
> Out[100]: False
>
> In [101]: isinstance(x, CFI)
> Out[101]: False
>
> In [105]: isinstance(e, CF)
> Out[105]: True
>
> This is not what I am looking for.
>
> I want to know to what class the CF primary key points to. So if it's
> CFT or CFI
>
> --
> 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.
>
>

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