Learn the basics of Django's Model Managers and Querysets

Поділитися
Вставка
  • Опубліковано 5 вер 2024

КОМЕНТАРІ • 46

  • @technotommy7002
    @technotommy7002 4 роки тому +15

    Bro. Your Django skill's is just awesome. It's like you are giving us paid course in free. Thanks man. God bless you.

  • @MadRad1000
    @MadRad1000 Рік тому

    Thank you, there are lots of Django tutorials on writing queries in the terminal, But it can be hard to find practical implementation ... you nailed it, perfectly clear now.

  • @zorojuro5106
    @zorojuro5106 4 роки тому +2

    You explain it to the point thanks dude, bless you, what ever you do u ll succeed

  • @Zzzzzzzzzzzzzzzzzzzzr
    @Zzzzzzzzzzzzzzzzzzzzr 5 років тому +1

    well done you should be at djangocon giving speeches.. well done brother.

  • @deep433
    @deep433 5 років тому +5

    you deserve at least 100k subscribers, really loved it......

  • @samiulsalehin1560
    @samiulsalehin1560 3 роки тому +1

    Thank you for this great tutorial. So far I've been searching, there are only custom queries using get, filter, etc. performed on any custom model manager. If my model name is 'SimpleModel' and the manager's name is 'SimpleModelManager', then what is the translation of 'SimpleModel,objects.all()' into the 'SimpleModelManager'?

  • @leadstn
    @leadstn 5 років тому +2

    please make a tutorial on how to deploy django channels on DigitalOcean and thank you for your great content

  • @MagnusAnand
    @MagnusAnand 3 роки тому

    Let me see if I understood correctly:
    You have the Model and you have the logic in the custom QuerySet. Then you implement a custom Manager that is the interface between the model and the QuerySet.
    Is this correct?
    Model Manager QuerySet ¿¿??

  • @VitaminCode
    @VitaminCode 3 роки тому +2

    I was unable to find your Django Website project on github

  • @talanky
    @talanky 2 роки тому

    Great explanation and example thanks

  • @AlexWinkler
    @AlexWinkler 4 роки тому

    Awesome video. How would one filter for the current user?
    Trying:
    class PortfolioManager(models.Manager):
    def get_queryset(self):
    return super().get_queryset().filter(user=self.request.user)
    Getting Error:
    'PortfolioManager' object has no attribute 'request'

    • @diegoman8158
      @diegoman8158 3 роки тому

      Almost a year late, but you could add an extra parameter to the method you are writing:
      models.py
      from django.db import models
      from django.conf import settings
      class OwnerManager(models.Manager):
      def owner(self, user):

      return self.filter(owner = user)
      class Text(models.Model):
      title = models.CharField(max_length=30, null=True)
      description = models.TextField(null=True)
      owner = models.ForeignKey(
      settings.AUTH_USER_MODEL,
      on_delete=models.CASCADE
      )
      objects = OwnerManager()
      views.py
      from django.views.generic import ListView
      from .models import Text
      class TextListOwner(ListView):
      model = Text
      def get_queryset(self):
      return self.model.objects.owner(self.request.user)

  • @mohammadmonirhossain6261
    @mohammadmonirhossain6261 4 роки тому +2

    Omg!!!!!!!
    Don't know how to thank enough

  • @ygcjayalal
    @ygcjayalal 3 роки тому

    wonderful...fantastic tutorial ..thank you so much... if you can, please do a tutorial about Django class base view please

  • @Sure_Math_Center
    @Sure_Math_Center Рік тому

    Nice video

  • @codybontecou
    @codybontecou 5 років тому

    Great video and explanation. It was exactly what I was looking for. Could you please link the documentation for this video and future content. I enjoy your explanations but sometimes it's nice to have a quick reference to where you are getting your information.

  • @TomiMcl
    @TomiMcl 5 років тому +1

    What is the difference adding methods in a custom manager or as a method in the model class?

  • @tarassavchenko2317
    @tarassavchenko2317 3 роки тому

    Your tutorials are gorgeous, thank you)

  • @radeonblue1816
    @radeonblue1816 2 роки тому

    What is the difference between QuerySet and manager? Can't I use just the class that inherits from Manager rather then using QuerySet? What is the disadvantage of this approach.

  • @collynchristopherbrenner3245
    @collynchristopherbrenner3245 3 роки тому

    Is there a way to not hard code the admin and editor_dude users into the view so as to make it dynamic? I'm trying to use a button to go from a project in Project model to its corresponding issue pulled from Issue model but I ma having a hard time passing the pk/id of the selected project to the following page that it links to which is supposed to display the issues of that project. (I don't know if a manager is what I need to use to do that or if there is a simpler solution, like a method that can grab the pk/id of the project from the address that the page links to (which I know you can do with PHP)).

  • @solo8003
    @solo8003 5 років тому +1

    very very nice and useful, can you help in how i can make only post author can edit or delete posts by model manger ?

    • @mattfreire
      @mattfreire  5 років тому

      That is something you configure with user permissions, not in a model manager.

  • @tobidegnon4409
    @tobidegnon4409 4 роки тому

    Hi, how is your vscode editor configured when you are using django, or can you do a video about plugins or tips for vscode related to django

  • @maxvinella941
    @maxvinella941 5 років тому +1

    Great tutorial! thanks

  • @MagnusAnand
    @MagnusAnand 3 роки тому

    Excellent video!

  • @abhishek9044855265
    @abhishek9044855265 4 роки тому

    Can we call django custom query manager from html template , in my case i am sending model class from views and in template i am trying to access model.objects.mycustommethod but it is throwing error by saying cant call manager method on model object instances . I am importing Post model from model.py to views.py then sending Post from views to html templates in context .

  • @ibrahime2193
    @ibrahime2193 3 роки тому

    good content, great future.

  • @Nadeemkhan-fs2ys
    @Nadeemkhan-fs2ys 5 років тому +2

    make a tutorial on complete crud operation in django in one video .. please

    • @mattfreire
      @mattfreire  5 років тому

      Am planning on it this year

    • @Nadeemkhan-fs2ys
      @Nadeemkhan-fs2ys 5 років тому

      @@mattfreire Thank you... Please quickly as soon as possible

    • @ravirsn9322
      @ravirsn9322 5 років тому

      go and try on javatpoint .... Easy to understand

  • @allenjack5340
    @allenjack5340 5 років тому

    what extensions did you use to make vs code suggesting django imports ?
    thanks for the explanation and keep it up please

    • @mattfreire
      @mattfreire  5 років тому

      +Allen Jack you can check the github project for the settings file in the .vscode folder. That file specifies the virtualenv directory which then suggests imports for you

  • @salmanmanzoorgorssi4114
    @salmanmanzoorgorssi4114 3 роки тому

    From where i can get this code

  • @user-de8ih7hs2e
    @user-de8ih7hs2e 5 років тому +1

    Cool!

  • @laticalamonzi2814
    @laticalamonzi2814 5 років тому +1

    thnx!

  • @xyzmoral262
    @xyzmoral262 5 років тому

    Thanks

  • @Akash-jz2vf
    @Akash-jz2vf 4 роки тому

    I think if you go a little bit slower, it will be more understandable and easy to follow for some.

  • @redred582
    @redred582 5 років тому

    i need the code for learn.. can u share to me?

  • @MagnusAnand
    @MagnusAnand 3 роки тому

    I can't find the source code in your github :o

  • @AlexWinkler
    @AlexWinkler 4 роки тому

    Amazing tutorial, I've been stuck so long on this SOF question I posted trying to filter my get_content_data and moving all those variable calculations to a manager seems to be the answer. Will post my solution here when I get it, Thanks! stackoverflow.com/questions/61973937/django-filter-queryset-show-variables-on-template

  • @alexanderdecember8743
    @alexanderdecember8743 4 роки тому

    Join previous comments!dont know how to thank