On Mon, Nov 23, 2009 at 9:09 AM, lfrodrigues <lfrodrig...@gmail.com> wrote:
> I guess this solution works but for +500000 the performance should be
> terrible...
>
> Shouldn't django have some option for this?

Could you set a field's value which is true for one, and false for the
other? Otherwise, could you just have two tables?

I wonder if ContentType could help?

        obj_type = ContentType.objects.get_for_model(player)
        source_refs = PlayerM.filter(object_type=obj_type)

(object_type gets created with generic relations)

-Doug

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

--

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