Skip to main content

Alphabetic template tag to filter django queryset

Project description

Django Template tag for building alphabetical index

Link to repository: https://github.com/Arpaso/alphabetic-simple

Builds alpabetic index to navigate through collection sorted by firstletter. Supports english and russian groups of alphabets.

Usage

view.py:

from django.views.generic.list_detail import object_list
from alphabetic.utils import alphabetic_setup
from .models import MyModel

    def myview(request):
        ...
        queryset = MyModel.objects.all()
        return object_list(request, alphabetic_setup(request, queryset, 'last_name'), template_name=template)

template.html:

{% show_alphabetic_filter %}

alphabetic_setup(request, queryset, ‘last_name’) - returns sorted queryset in alphabetical order by firstletter of the attribute name, e.g. last_name or whatever attribute of the model you specified.

show_alphabetic_filter - template tag shows clickable alphabet in the template.

Clicking on the letter will produce GET request to the current url with a tail ?firstletter=X, where X is the clicked letter.

Written by the development team of Arpaso company: http://arpaso.com

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alphabetic-simple-0.2.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file alphabetic-simple-0.2.tar.gz.

File metadata

File hashes

Hashes for alphabetic-simple-0.2.tar.gz
Algorithm Hash digest
SHA256 c44b5e9b98cc4c16584aa9b21995b94e4eed9107a694e28ab6bb02a33d57ef3d
MD5 964512d5318d3e1ccad009bcecc5fc44
BLAKE2b-256 a439b1c35c8667d3ad6b3a292efca37ce26bc3952ddec876087d3c57ac82a76e

See more details on using hashes here.

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