Saturday, July 23, 2016

Re: When it make sense to use a different name for a custom manager of the Django`s model?

Sorry, Derek but I am do not understand your answer.

"(but of course should be a name that makes sense for your app)" - Why? I was completely satisfied with default manager`s name - "objects"

In my project, I am using next code:

class Poll(models.Model):
[fields and class Meta]
objects = models.Manager() objects = PollManager.from_queryset(PollQuerySet)()

[other code]

where PollManager is my custom manager, PollQuerySet - my custom QuerySet for the model Poll

If I follow your`s advice then must next:

class Poll(models.Model):
[fields and class Meta]
objects = models.Manager() polls = PollManager.from_queryset(PollQuerySet)()

[other code]




On Sat, Jul 23, 2016 at 5:48 PM, Derek <gamesbook@gmail.com> wrote:
https://docs.djangoproject.com/en/1.9/topics/db/managers/#modifying-a-manager-s-initial-queryset

Note the difference between overriding the default queryset (called "objects" by Django) vs creating your own - in the example shown, it is called "dahl_objects" (but of course should be a name that makes sense for your app).

On Saturday, 23 July 2016 12:32:32 UTC+2, Seti Volkylany wrote:
If why know good article about it, send me link, I will resolve of itself.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/Oqq48vVqVFM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/415c3f1c-4d3d-41f5-b2e5-49c3b7db7e1e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGWd_9K8Q9fQ%2B1x7-e%2BwHMQBEyDNYHMhoxtuLjNKp%2BEPHuiD0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment