templates

Django custom error pages (404, 500)

Custom error pages improve user experience and brand consistency. I create templates named 404.html, 500.html, 403.html, and 400.html in the templates root. Django serves these automatically when DEBUG=False. For custom logic, I can override error han

Django custom template filters for formatting

Custom template filters transform variables in templates. I decorate functions with @register.filter and optionally set is_safe=True for HTML output. Filters take one or two arguments. For formatting dates, numbers, or text, filters keep logic out of

Django custom template tags for reusable components

Template tags extend Django's template language. I create simple tags with @register.simple_tag and inclusion tags with @register.inclusion_tag for rendering template snippets with context. Assignment tags store results in template variables. I place

Django email with HTML templates

I send HTML emails using Django templates for consistent branding. The EmailMultiAlternatives class supports both plain text and HTML versions. I render templates with render_to_string and context data. For transactional emails, I queue them via Celer

Django context processors for global template variables

Context processors add variables to every template context automatically. I create a function that takes request and returns a dict. This is perfect for site-wide settings like site name, current year, or user preferences. I add my processor to TEMPLA