how to write re-usable views in django?
- by rz
These are the techniques that I use regularly to make my views reusable:
take the template_name as an argument with a default
take an optional extra_context which defaults to empty {}
right before the template is rendered the context is updated with the extra_context
for further re-usability, call any callable in extra_context.values()
whenever…