Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peopledoc/django-navigator
Let you navigate between object DetailView from a ListView or a SearchView.
https://github.com/peopledoc/django-navigator
approved-public ghec-mig-migrated
Last synced: 17 days ago
JSON representation
Let you navigate between object DetailView from a ListView or a SearchView.
- Host: GitHub
- URL: https://github.com/peopledoc/django-navigator
- Owner: peopledoc
- License: other
- Created: 2012-12-04T09:41:37.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-09-30T07:59:05.000Z (over 8 years ago)
- Last Synced: 2024-04-16T06:52:49.520Z (9 months ago)
- Topics: approved-public, ghec-mig-migrated
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 8
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
**WARNING: this project is not maintained**
################
Django Navigator
################A little module that let you navigate from DetailView to DetailView
with previous and next button from a ListView or a SearchView.USAGE
=====Create your own **navigator.py**::
import navigator
from myapp.models import Documentclass DocumentNavigator(navigator.Navigator):
session_id = 'document_navigator_ids'
url_id = 'my_app:document_preview'
def __init__(self, current_doc_id, owner):
queryset = Document.objects.of(owner).order_by('created_at')
super(DocumentNavigator, self).__init__(current_doc_id, queryset)In the **views.py**::
from django.views.generic import DetailView
from myapp.models import Document
from myapp.navigator import DocumentNavigatorclass DocumentPreview(DetailView):
"""Display the preview of the document"""
template_name = "my_app/document_preview.html"
model = Document
slug_field = 'uuid'
def get_queryset(self):
queryset = super(DocumentPreview, self).get_queryset()
return queryset.of(self.request.user)
def get_context_data(self, **kwargs):
data = super(DocumentPreview, self).get_context_data(**kwargs)
data['navigator'] = DocumentNavigator(obj.uuid, self.request.user)
data['navigator'].set_ids(self.request.session)
return dataIn the **template.html**::
{% if navigator.previous or navigator.next %}
{% endif %}Then you have previous and next buttons in you DetailView and that's it !