I need to filter database by default every time that I see it (when I save changes or when I open database first time).
Can anybody tell me how to do it?
I need to filter database by default every time that I see it (when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is possible with custom custom Managers:
Say you have a class called
Book:And you want the admin pages for book objects to only show books by Roald Dahl, then you can add a custom manager:
Then you just need to specify that your
ModelAdminshould use thedahl_objectsmanager, which is explained here.