On Feb 27, 12:25 pm, Calvin Spealman <[email protected]> wrote:
> On Fri, Feb 27, 2009 at 11:45 AM, Øyvind Saltvik
> > Should be doable but you need to filter on a field of the subclass
> > being null.
>
> > SomeModel.objects.filter(somemodelsubclass__somefield=None) ,
> > somefield cannot be id or pk.
>
> That is one method I found, but it seems very incorrect to add a field
> just for this, with no real data. I was wondering if it would be
> appropriate to add to every model subclass a "fake" field or simply to
> add to the query API, so that someone could do
> SomeModel.objects.filter(somesubclass__isinstance=True). The
> hypothetical name here is chosen for obvious reasons. Alternatively,
> something aside from filter might be appropriate, like
> SomeModel.objects.instancesof(SomeModelSubclass).
>
> Should I file a ticket? I would like to look at contributing an
> implementation of whichever would be favorable, if either would be up
> for consideration.

I wrote about something similar on my blog, which lets you filter for
instances of a Model which are not actually instances of any children
models. The link is at 
http://sciyoshi.com/blog/2008/aug/07/custom-django-manager-excludes-subclasses/
- might be possible (and probably not too hard) to customize it for
your case.

Hope that can be of help!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to