Snippet List
View mixin and utils to generate PDF documents from html using *xhtml2pdf*.
The most interesting thing here is *PDFTemplateResponseMixin*.
Adding this mixin to class based views allows automatic pdf generation using
the view context and a customized template.
There is also the lower level function *render_to_pdf*, similar to what can be
seen in [snippet 659](http://djangosnippets.org/snippets/659/).
See the docstrings for a detailed explanation.
- pdf
- mixin
- class-based-views
A collection of utilities for admin log entries management.
This module provides functions to add log entries for instance addition,
change and deletion, as seen in *django.contrib.admin.options*.
It also provides a class based view mixin to add logging capabilities,
and other tools as a log collector.
See docstrings for a better description.
You can use this function to change an admin option dynamically.
For example, you can add a custom callable to *list_display* based on request, or if the current user has required permissions, as in the example below:
class MyAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'other_field')
def changelist_view(self, request, extra_context=None):
if request.user.is_superuser:
add_dynamic_value(self, 'list_display', my_custom_callable)
return super(MyAdmin, self).changelist_view(request, extra_context)
- admin
- list_display
- list_filter
frankban has posted 3 snippets.