While we're talking about that, is there a reason the default manager
isn't iterable (default mapping to .all()) ?

This is not as trivial as it sounds, because it means template writers
need to be aware of which member of the class are managers and which
are plain methods returning lists or querysets. For example:

{% for comment in blogpost.comments_set.all %}
vs
{% for comment in blogpost.custom_comments_method %}

There might be a good reason why it's like that, otherwise I'll
propose a patch...

Regards,
Philippe


On Thu, Oct 22, 2009 at 3:11 PM, Luke Plant <l.plant...@cantab.net> wrote:
>
> On Thursday 22 October 2009 12:45:13 Waldemar Kornewald wrote:
>> Hi, just a small issue we always wondered about:
>> Why doesn't Model provide a simple .all() function which just maps
>>  to self.objects.all() or self._default_manager.all()? Only few
>>  models provide multiple managers and it's annoying to write
>>  .objects everywhere. Is there a good reason to force people to
>>  write ".objects" all the time?
>
> Remember that methods on Model will be available to instances of
> Model.  Therefore it's really important not to pollute the namespace,
> which is shared with model field attributes.  Therefore, we decided on
> a single standard way to distinguish 'table level' attributes from
> 'row level', and that is ".objects".  Adding more methods to Model
> would only cause more potential conflicts with field names.
>
> Luke
>
> --
> "Some people says that if you play a Windows XP install CD
> backwards you will hear demon voices commanding you to worship
> Satan. But that's nothing. If you play it forwards it will install
> Windows XP."
>
> Luke Plant || http://lukeplant.me.uk/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to