Created
July 25, 2024 14:25
-
-
Save TohidN/e326e010055c76dad1785f76aee3c2ad to your computer and use it in GitHub Desktop.
Abstract Wagtail page model to allow HTMX partial page load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Implementation of HTMX - Partial Page Load for wagtail instead of django. all wagtail pages with htmx only need to inherit from
HtmxPagemodel instead of wagtail'sPagemodel.