1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How do calls of models.Manager and custom managers work?

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    The following question was asked by a different user that subsequently removed the question. But I think it is useful to "dig" a bit in how Django's manager logic works.


    I extended the models.Manager class and created a custom manager.

    class
    PublishedManager(models.Manager):
    def get_queryset(self):
    return super().get_queryset().filter(status=Post.Status.PUBLISHED)

    It's more than understandable, BUT how do calls of managers work?

    objects = models.Manager() # The
    default manager. published = PublishedManager() # Our custom manager.

    I don't address get_queryset() method, I just call constructors. Then how does it work?
    ​

    Continue reading...

Compartilhe esta Página