Skip to content

Instantly share code, notes, and snippets.

@TohidN
Created July 25, 2024 14:25
Show Gist options
  • Select an option

  • Save TohidN/e326e010055c76dad1785f76aee3c2ad to your computer and use it in GitHub Desktop.

Select an option

Save TohidN/e326e010055c76dad1785f76aee3c2ad to your computer and use it in GitHub Desktop.
Abstract Wagtail page model to allow HTMX partial page load
class HtmxPage(Page):
def get_context(self, request):
context = super().get_context(request)
context['base_template'] = "partial.html" if request.htmx else "base.html"
return context
class Meta:
abstract = True
@TohidN
Copy link
Author

TohidN commented Jul 25, 2024

Implementation of HTMX - Partial Page Load for wagtail instead of django. all wagtail pages with htmx only need to inherit from HtmxPage model instead of wagtail's Page model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment