The QuerySet method examples [1] mostly use the corresponding Manager  
proxy method.
Probably QuerySet.create() exists to use querysets where managers are  
expected.

An ugly corner case:

cat.article_set.filter(...).create(title=title)

is equivalent to

Article.objects.create(title=title)


[1] http://www.djangoproject.com/documentation/db-api/#queryset- 
methods-that-do-not-return-querysets


Am 16.06.2008 um 21:06 schrieb Ken Arnold:

>
> True. But surprisingly enough, the `create` method is a QuerySet
> instance method. And it doesn't use any of the filtering, so
>
>     Article.objects.filter(category=cat).create(title=title,
> content=content)
>
> doesn't do what you'd expect. (Though `cat.article_set.create` should
> work.) Has that actually confused anyone?
>
> -Ken
>
>
> On Jun 16, 2:57 pm, Johannes Dollinger
> <[EMAIL PROTECTED]> wrote:
>>> So then what is the difference between a Manager and a QuerySet?
>>
>>> Nearly everything would work identically if Manager were simply:
>>
>>> class Manager(QuerySet):
>>>     pass
>>
>>> (except actually keeping the magic that connects it to the model
>>> class.)
>>
>> Utility methods in managers wouldn't make much sense if Manager was a
>> QuerySet:
>>
>> User.objects.filter(username='foo').create_user('bar',
>> '[EMAIL PROTECTED]')
>>
>> Although those utilities could as well be class methods.
> >



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to