Socket
Socket
Sign inDemoInstall

django-search-listview

Package Overview
Dependencies
0
Maintainers
2
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    django-search-listview

Searchable and paginable ListView


Maintainers
2

Readme

Django-SearchableListView

Build Status Coverage Status Code Health

ListView which can be searchable, paginate and which doesn'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

pip install django-search-listview
INSTALLED_APPS = [
    ...
    'search_listview',
]

Only paginate ListView

from search_listview.list import SearchableListView

class ListDevicePaginate(SearchableListView):
    model = Device
    template_name = "tests/list.html"
    paginate_by = 10

Paginate + Searchable ListView

from search_listview.list import SearchableListView

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
<div class="row">
    {% include "search_listview/search_and_page.html" %}
</div>
  • In the footer
<!--Need jQuery-->
<script src="{% static 'search_listview/js/search_listview.js' %}"></script>
<script>
    start_search()
</script> 

Now you have a beautifull box with all the fields you need.

Alt tag

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc