I guess this solution works but for +500000 the performance should be
terrible...

Shouldn't django have some option for this?

On 23 Nov, 04:53, Preston Holmes <pres...@ptone.com> wrote:
> Perhaps there is a more efficient way, but in my quick test, one can't
> filter() a queryset based on __class__ of the model, but seems one can
> manually filter it afterwords:
>
> qs = Player.objects.all()
> for i,obj in enumerate(qs):
>     if obj.__class__ != Player:
>         del(qs[i])
>
> On Nov 22, 4:32 pm, lfrodrigues <lfrodrig...@gmail.com> wrote:
>
> > Hello,
>
> > I have these models:
>
> > class Player(models.Model):
> >     .....
>
> > class PlayerM(Player):
> >     ...
>
> > If I do PlayerM.objects.all() e get all PlayerM objects and for
> > Player.objects.all() I get all Player and PlayerM as expected.
>
> > How can get only the objects of type Player (only retrieve the objects
> > that were created with Player() constructor)?
>
> > Regards,
>
> > Luis

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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=.


Reply via email to