Searchable and paginable ListView
Project description
Django-SearchableListView
=========================
[![Build Status](https://travis-ci.org/SchroterQuentin/Django-SearchableListView.svg?branch=master)](https://travis-ci.org/SchroterQuentin/Django-SearchableListView)
[![Coverage Status](https://coveralls.io/repos/github/SchroterQuentin/Django-SearchableListView/badge.svg)](https://coveralls.io/github/SchroterQuentin/Django-SearchableListView)
ListView which can be searchable, paginate and which don't lose query parameter and page number
Installation
------------
This library need jQuery ( and Bootstrap for the frond-end )
To install it in your vitualenv on your django project
```{r, engine='bash', count_lines}
pip install django_search_model
```
Only paginate ListView
----------------------
```python
class ListDevicePaginate(SearchableListView):
model = Device
template_name = "tests/list.html"
paginate_by = 10
```
Paginate + Searchable ListView
------------------------------
```python
class ListDeviceSearchablePaginate(SearchableListView):
model = Device
template_name = "tests/list.html"
paginate_by = 10
searchable_fields = ["inventory_number", "model_device", "model_device__brand__provider",
"model_device__brand__name"]
specifications = {
"model_device__brand__name": "__icontains"
}
```
Put the parameter for the query in **searchable_fields** which will be use to filter the queryset. The specifications which be use in the same way.
In the template
---------------
- Where you want the pagination and the search box
```html
<div class="row">
{% include "search_listview/search_and_page.html" %}
</div>
```
- In the footer
```html
<!--Need jQuery-->
<script src="{% static 'js/django_search_model.js' %}"></script>
<script>
start_search()
</script>
```
Now you have a beautifull box with all the fields you need.
![Alt tag](/docs/search_box.png?raw=true "Search box")
=========================
[![Build Status](https://travis-ci.org/SchroterQuentin/Django-SearchableListView.svg?branch=master)](https://travis-ci.org/SchroterQuentin/Django-SearchableListView)
[![Coverage Status](https://coveralls.io/repos/github/SchroterQuentin/Django-SearchableListView/badge.svg)](https://coveralls.io/github/SchroterQuentin/Django-SearchableListView)
ListView which can be searchable, paginate and which don't lose query parameter and page number
Installation
------------
This library need jQuery ( and Bootstrap for the frond-end )
To install it in your vitualenv on your django project
```{r, engine='bash', count_lines}
pip install django_search_model
```
Only paginate ListView
----------------------
```python
class ListDevicePaginate(SearchableListView):
model = Device
template_name = "tests/list.html"
paginate_by = 10
```
Paginate + Searchable ListView
------------------------------
```python
class ListDeviceSearchablePaginate(SearchableListView):
model = Device
template_name = "tests/list.html"
paginate_by = 10
searchable_fields = ["inventory_number", "model_device", "model_device__brand__provider",
"model_device__brand__name"]
specifications = {
"model_device__brand__name": "__icontains"
}
```
Put the parameter for the query in **searchable_fields** which will be use to filter the queryset. The specifications which be use in the same way.
In the template
---------------
- Where you want the pagination and the search box
```html
<div class="row">
{% include "search_listview/search_and_page.html" %}
</div>
```
- In the footer
```html
<!--Need jQuery-->
<script src="{% static 'js/django_search_model.js' %}"></script>
<script>
start_search()
</script>
```
Now you have a beautifull box with all the fields you need.
![Alt tag](/docs/search_box.png?raw=true "Search box")
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-search-listview-0.1.tar.gz
(12.7 kB
view hashes)
Close
Hashes for django-search-listview-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ad0e2b56d6f235a8f2386d7cf88ffd075ebdf52e2d52b0ba3bfa4f59b349d02 |
|
MD5 | ebef672418dd4cfa4cf43ba2c74c5a80 |
|
BLAKE2b-256 | 7e05983c0a393a6df22e0f4bee1cb99da71bc3e244696f2d57afa1ba05abf44f |