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'?
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
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'
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)
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.
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)).
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 ¿¿??
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.
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 .
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.
+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
Bro. Your Django skill's is just awesome. It's like you are giving us paid course in free. Thanks man. God bless you.
certified
I was unable to find your Django Website project on github
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'?
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
please make a tutorial on how to deploy django channels on DigitalOcean and thank you for your great content
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'
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)
you deserve at least 100k subscribers, really loved it......
+1
You explain it to the point thanks dude, bless you, what ever you do u ll succeed
well done you should be at djangocon giving speeches.. well done brother.
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.
Omg!!!!!!!
Don't know how to thank enough
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)).
wonderful...fantastic tutorial ..thank you so much... if you can, please do a tutorial about Django class base view please
From where i can get this code
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 ¿¿??
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.
Nice video
very very nice and useful, can you help in how i can make only post author can edit or delete posts by model manger ?
That is something you configure with user permissions, not in a model manager.
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 .
What is the difference adding methods in a custom manager or as a method in the model class?
readability and scalable
I think if you go a little bit slower, it will be more understandable and easy to follow for some.
Cool!
thnx!
Great tutorial! thanks
I can't find the source code in your github :o
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.
Great explanation and example thanks
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
Join previous comments!dont know how to thank
make a tutorial on complete crud operation in django in one video .. please
Am planning on it this year
@@mattfreire Thank you... Please quickly as soon as possible
go and try on javatpoint .... Easy to understand
good content, great future.
Excellent video!
Your tutorials are gorgeous, thank you)
i need the code for learn.. can u share to me?
what extensions did you use to make vs code suggesting django imports ?
thanks for the explanation and keep it up please
+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
Thanks