Skip to main content

Django AJAX ModelForms. Read-only display ModelForms. Django AJAX grids with CRUD and custom actions. Supports DTL.

Project description

https://badge.fury.io/py/django-jinja-knockout.png

Screenshot of sample application:

https://raw.githubusercontent.com/wiki/Dmitri-Sintsov/djk-sample/djk_edit_inline.png

More screenshots with description are available at: https://github.com/Dmitri-Sintsov/djk-sample/wiki

Sample application: https://github.com/Dmitri-Sintsov/djk-sample

Documentation (in development): https://django-jinja-knockout.readthedocs.org/

Key features

  • Django 1.8, 1.9. 1.10 support. Python 3.4 / 3.5 support.

  • Bootstrap 3 / Jinja2 / Knockout.js integration into Django projects.

  • No deep knowledge of Knockout.js is required: it has ready working components.

  • Dynamic adding / removing of inline formsets with Knockout.js, protected from XSS.

  • Django raw queries with filter() / exclude() / order() / values() / values_list() and SQL slicing support via FilteredRawQuerySet, suitable for ListView / ListSortingView / KoGridView.

  • Knockout.js powered AJAX django.admin-like grids (paginated tables) with sorting / filters and custom actions.

  • ForeignKeyGridWidget provides ForeignKeyRawIdWidget-like functionality to select ModelForm foreign key field value via AJAX query / response.

  • Supports existing Django templates (DTL). Jinja2 templates can be integrated into existing Django templates via custom template library tag:

    {% extends 'base_min.html' %}
    {% load jinja %}
    {% load staticfiles %}
    
    {% block main %}
    {% jinja 'bs_list.htm' with _render_=1 view=view object_list=object_list is_paginated=is_paginated page_obj=page_obj %}
    {% endblock main %}

Major changes (version 0.2.0)

$.inherit() Javascript prototype inheritance function now supports multi-level inheritance with nested .super calls without having to specify parent class prototype property implicitely in descendant class instances, with newly introduced $.SuperChain class.

“django.admin-like” AJAX functionality was implemented via KoGridView class-based view (CBV) at server-side with corresponding Knockout.js templates and Javascript classes at client-side. Besides providing standard CRUD actions and filters, it allows to implement arbitrary actions in descendant classes and quickly design django.admin-like user interfaces in non-admin views. AJAX calls also minimize server HTTP traffic, reducing network bandwitch and making the UI more responsive.

New ForeignKeyGridWidget was developed which provides ForeignKeyRawIdWidget-like functionality in non-admin ModelForm classes to select foreign key fields value via AJAX query / response.

Support of auto-instantiating Javascript classes with binding these to selected DOM nodes with ‘component’ css class via App.Components class.

Support of auto-compiling / auto-loading client-side underscore.js templates via App.compileTemplate / App.domTemplate / App.loadTemplates. One of usage examples is the possibility of loading modal body from underscore.js template in App.Dialog.

Support of client-side generation of view urls with kwargs for client-side url names via updated context_processors.py and client-side App.routeUrl() Javascript function.

tpl.resolve_cbv() allows to resolve view class via url name and it’s kwargs.

Django templates (DTL) and Jinja2 templates now can be mixed using shared Jinja2 template code via {% load jinja %} template library jinja template tags, which performs include for Jinja2 template with current context:

{% extends 'base_min.html' %}
{% load jinja %}
{% load staticfiles %}

{% block main %}
{% jinja 'bs_list.htm' with _render_=1 view=view object_list=object_list is_paginated=is_paginated page_obj=page_obj %}
{% endblock main %}

Numerous bug fixes.

Documentation

The full documentation is at https://django-jinja-knockout.readthedocs.org.

Cookiecutter Tools Used in Making This Package

  • cookiecutter

  • cookiecutter-djangopackage

History

0.1.0

  • To be released on PyPI.

0.2.0

  • Django 1.8 / 1.9 / 1.10, Python 3.4 / 3.5 support.

  • djk-sample demo / automated testing project.

  • “django.admin-like” AJAX functionality implemented via KoGridView class-based view.

  • $.inherit() Javascript prototype inheritance function now supports multi-level inheritance with nested ._super._call().

  • FilteredRawQuerySet supports Django raw querysets with .filter() / .exclude() / .order_by() / .values() / .values_list() and SQL level slicing.

  • ForeignKeyGridWidget provides ForeignKeyRawIdWidget -like functionality via AJAX query / response in non-admin forms to select ModelForm foreign key values.

  • Client-side generation of view urls with kwargs in Javascript client-side routes via App.routeUrl().

  • Nested autocompiled underscore.js client-side templates for Javascript components, primarily used with Knockout.js, but is not limited to.

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-jinja-knockout-0.2.0.tar.gz (452.2 kB view hashes)

Uploaded Source

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