https://github.com/eieste/django-partitialajax
https://github.com/eieste/django-partitialajax
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/eieste/django-partitialajax
- Owner: eieste
- License: mit
- Created: 2019-12-16T19:01:14.000Z (over 6 years ago)
- Default Branch: development
- Last Pushed: 2023-01-07T13:06:37.000Z (over 3 years ago)
- Last Synced: 2024-05-01T15:56:39.231Z (about 2 years ago)
- Language: Python
- Size: 590 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Partitial Ajax
[](https://circleci.com/gh/eieste/django-partitialajax/tree/development)
[](https://coveralls.io/github/eieste/django-partitialajax?branch=development)





This libary can you help to load Django-Rendered Partitials and embedd this into your page.
This libary consists of two parts: python/django and js lib;
you can install it via
```bash
pip3 install django-partitialajax
npm install django-partitialajax
```
For more Information read the [Documentation](https://django-partitialajax.readthedocs.io/en/latest/)
## Quick start
settings.py
```python
INSTALLED_APPS = [
...
partitialajax
]
```
views.py
```python
from partitialajax.mixin import ListPartitialAjaxMixin
from django.views.generic import ListView
class BookListItem(ListPartitialAjaxMixin, ListView):
template_name = "book/list.html"
model = Book
partitial_list = {
"tbody#book-list-partitial":"book/partitial/list.html"
}
```
book/list.html
```html
{% load partitialajax %}
ID
Name
Author
{% direct "tbody#book-list-partitial" %}
```
book/partitial/list.html
```html
{% for book in object_list %}
{{object.pk}}
{{object.name}}
{{object.author}}
{% endfor %}
```
## And what's different about an include now?
an include is rendered directly by django, so that no update can take place in the client side.
With django-partitialajax you can reload this part.
How? Just use the following JS code
```js
import {PartitialAjax} from "django-partitialajax";
let partitial_element = document.getElementById("book-list-partitial");
let partitial = PartitialAjax.getPartitialFromElement(partitial_element);
partitial.getFromRemote();
```