How to use custom AdminSite class?

The Problem Using a custom class derived from django.contrib.admin.AdminSite for the admin site of a project, without having to write custom registration code to register models with the new class. When I use 3rd party apps with their own models, I’d rather not have to edit custom registration code only because models were added or … Read more

XlsxWriter object save as http response to create download in Django

A little update on @alecxe response for Python 3 (io.BytesIO instead of StringIO.StringIO) and Django >= 1.5 (content_type instead of mimetype), with the fully in-memory file assembly that has since been implemented by @jmcnamara ({‘in_memory’: True}) ! Here is the full example : import io from django.http.response import HttpResponse from xlsxwriter.workbook import Workbook def your_view(request): … Read more

“{% extends %}” vs “{% include %}” in Django Templates

Extending allows you to replace blocks (e.g. “content”) from a parent template instead of including parts to build the page (e.g. “header” and “footer”). This allows you to have a single template containing your complete layout and you only “insert” the content of the other template by replacing a block. If the user profile is … Read more