How can I use Django list and filtering in my own views?
I'm just getting started with Django and I love the auto-list in Django admin and the way I set up filters and columns to show. Can I use it in my own applications?
Ive looked into the source for the admin and realized that I probably want to subclass the "ChangeList" object in some way and use it in my own views. Any ideas?
You'd better do the following.
-
Define a plain old Django query for various filters. They are very easy to write.
-
Use the supplied generic functions . They are very easy to use.
-
Create your own templates with links to your filters. You will create links to the list based on the query results. For a few hardcoded cases, this is very easy. In the case of a super-generic admin interface, it's not easy.
Be the first to do it. Get it to work. It does not take much time. It is very important to understand Django at this level before diving into how admin applications work.
Later - after you have something working, you can spend a few hours learning how the inner secrets of the admin interface work.
a source to share