@@ -715,29 +715,26 @@ Generic views
715
715
The ``tagging.views `` module contains views to handle simple cases of
716
716
common display logic related to tagging.
717
717
718
- ``tagging.views.tagged_object_list ``
719
- ------------------------------------
718
+ ``tagging.views.TaggedObjectList ``
719
+ ----------------------------------
720
720
721
721
**Description: **
722
722
723
723
A view that displays a list of objects for a given model which have a
724
724
given tag. This is a thin wrapper around the
725
- ``django.views.generic.list_detail.object_list `` view, which takes a
725
+ ``django.views.generic.list.ListView `` view, which takes a
726
726
model and a tag as its arguments (in addition to the other optional
727
- arguments supported by ``object_list ``), building the appropriate
727
+ arguments supported by ``ListView ``), building the appropriate
728
728
``QuerySet `` for you instead of expecting one to be passed in.
729
729
730
730
**Required arguments: **
731
731
732
- * ``queryset_or_model ``: A ``QuerySet `` or Django model class for the
733
- object which will be listed.
734
-
735
732
* ``tag ``: The tag which objects of the given model must have in
736
733
order to be listed.
737
734
738
735
**Optional arguments: **
739
736
740
- Please refer to the `object_list documentation `_ for additional optional
737
+ Please refer to the `ListView documentation `_ for additional optional
741
738
arguments which may be given.
742
739
743
740
* ``related_tags ``: If ``True ``, a ``related_tags `` context variable
@@ -751,12 +748,12 @@ arguments which may be given.
751
748
752
749
**Template context: **
753
750
754
- Please refer to the `object_list documentation `_ for additional
751
+ Please refer to the `ListView documentation `_ for additional
755
752
template context variables which may be provided.
756
753
757
754
* ``tag ``: The ``Tag `` instance for the given tag.
758
755
759
- .. _`object_list documentation` : http ://docs.djangoproject.com/en/dev /ref/generic-views/#django -views- generic-list-detail-object-list
756
+ .. _`ListView documentation` : https ://docs.djangoproject.com/en/1.8 /ref/class-based -views/ generic-display/#listview
760
757
761
758
Example usage
762
759
~~~~~~~~~~~~~
@@ -766,15 +763,13 @@ list items of a particular model class which have a given tag::
766
763
767
764
from django.conf.urls.defaults import *
768
765
769
- from tagging.views import tagged_object_list
766
+ from tagging.views import TaggedObjectList
770
767
771
768
from shop.apps.products.models import Widget
772
769
773
770
urlpatterns = patterns('',
774
- url(r'^widgets/tag/(?P<tag>[^/]+)/$',
775
- tagged_object_list,
776
- dict(queryset_or_model=Widget, paginate_by=10, allow_empty=True,
777
- template_object_name='widget'),
771
+ url(r'^widgets/tag/(?P<tag>[^/]+(?u))/$',
772
+ TaggedObjectList.as_view(model=Widget, paginate_by=10, allow_empty=True),
778
773
name='widget_tag_detail'),
779
774
)
780
775
@@ -783,13 +778,10 @@ perform filtering of the objects which are listed::
783
778
784
779
from myapp.models import People
785
780
786
- from tagging.views import tagged_object_list
781
+ from tagging.views import TaggedObjectList
787
782
788
- def tagged_people(request, country_code, tag ):
783
+ class TaggedPeopleFilteredList(TaggedObjectList ):
789
784
queryset = People.objects.filter(country__code=country_code)
790
- return tagged_object_list(request, queryset, tag, paginate_by=25,
791
- allow_empty=True, template_object_name='people')
792
-
793
785
794
786
Template tags
795
787
=============
0 commit comments