O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.7 Making PostGetMixin Generic

If you examine the current iteration of PostGetMixin, you might notice we’re only a few steps away from very generic behavior. For our site, falling down the rabbit hole isn’t all that helpful. On a larger project, where we might need very specific generic behavior, creating such behavior might prove to be incredibly beneficial. In the interest of uncovering all of the secrets of building your own GCBV classes, we will thus follow the rabbit down the rabbit hole.

The first thing to do is make it so that the pub_date is not hardcoded in the class. In Example 18.39, we introduce the date_field attribute (with a smart default for our own site) and use that attribute in a dictionary that we use for filter arguments ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required