Skip to main content

Viewsets for Django using HTMX, Chartjs and DataTables

Project description

Django CI codecov Maintainability License: GPL v3

django-htmx-viewsets

Viewsets for Django using HTMX and DataTables

Built with

Description

When working with Django REST framework you will stumble upon so called ViewSets. They allow you to combine a set of related Views without repeating. This aproach has no counterpart in Django itself.

Therefore I created this package.

Features

  • Create a viewset with one line
  • Dynamic loading of DetailView, UpdateView, CreateView and DeleteView
  • Urls are auto created
  • Queryset group by, filter and exclude by all possible date and time transform lookups
  • Auto create mixed chart with AJAX loading
  • Auto create table with AJAX loading
  • Customizable architecture[^1]

[^1]: Things may change while in early state (<1.0.0)

Quick-Start

Installation

pip install django-htmx-viewset

views.py

Create a ModelViewset by passing the model

MainViewSet = modelviewset_factory(model=Main)

or a queryset

MainViewSet = modelviewset_factory(queryset=Main.objects.all())

urls.py

app_name = 'test_db'
urlpatterns = [
    path('main/', include(MainViewSet.urls)),
]

Template

Project contains a full template. If you want to use your own template, you can overwrite the template (htmx_viewsets/full.html) or pass the full_template_name as kwarg to modelviewset_factory. The template should contain the following tags and blocks:

{% load htmx_viewsets %}
<html>
  <head>
    {% htmx_viewsets_static_all %}
  </head>
  <body>
    {% block main %}{% endblock main %}
    {% htmx_viewsets_fixed_content %}
  </body>
</html>

htmx_viewsets_static_all can be splitted by using htmx_viewsets_static_js and htmx_viewsets_static_css.

htmx_viewsets_fixed_content can be splitted by using htmx_viewsets_modal and htmx_viewsets_messages.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-htmx-viewsets-0.0.5.tar.gz (804.5 kB view details)

Uploaded Source

Built Distribution

django_htmx_viewsets-0.0.5-py3-none-any.whl (809.1 kB view details)

Uploaded Python 3

File details

Details for the file django-htmx-viewsets-0.0.5.tar.gz.

File metadata

  • Download URL: django-htmx-viewsets-0.0.5.tar.gz
  • Upload date:
  • Size: 804.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for django-htmx-viewsets-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7b991efae8529c4aeaab91dded018a0a033b22799805bd3e70249a729bd10f52
MD5 7b323ae2cd4ecd9223345624ee445a1c
BLAKE2b-256 52585564aff712803d4595bc38e6568805e78173c0f364e6ddfa3ef649a1e723

See more details on using hashes here.

Provenance

File details

Details for the file django_htmx_viewsets-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_htmx_viewsets-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c9ce03ecfbcd82591c0baa5f77e1f8a0a4a7d58edff7b4200093f3181d1926f8
MD5 ca56d2c6fdb05e2a73bb663a812ff132
BLAKE2b-256 39dc3e8b6557fa033134c36bd6fdeb85a101c6d1eb3b5ed90c44b5831a2b21ae

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page