Skip to content

Commit 7cb07c0

Browse files
committed
Update documentation for views
1 parent a6e392b commit 7cb07c0

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

docs/index.rst

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -715,29 +715,26 @@ Generic views
715715
The ``tagging.views`` module contains views to handle simple cases of
716716
common display logic related to tagging.
717717

718-
``tagging.views.tagged_object_list``
719-
------------------------------------
718+
``tagging.views.TaggedObjectList``
719+
----------------------------------
720720

721721
**Description:**
722722

723723
A view that displays a list of objects for a given model which have a
724724
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
726726
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
728728
``QuerySet`` for you instead of expecting one to be passed in.
729729

730730
**Required arguments:**
731731

732-
* ``queryset_or_model``: A ``QuerySet`` or Django model class for the
733-
object which will be listed.
734-
735732
* ``tag``: The tag which objects of the given model must have in
736733
order to be listed.
737734

738735
**Optional arguments:**
739736

740-
Please refer to the `object_list documentation`_ for additional optional
737+
Please refer to the `ListView documentation`_ for additional optional
741738
arguments which may be given.
742739

743740
* ``related_tags``: If ``True``, a ``related_tags`` context variable
@@ -751,12 +748,12 @@ arguments which may be given.
751748

752749
**Template context:**
753750

754-
Please refer to the `object_list documentation`_ for additional
751+
Please refer to the `ListView documentation`_ for additional
755752
template context variables which may be provided.
756753

757754
* ``tag``: The ``Tag`` instance for the given tag.
758755

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
760757

761758
Example usage
762759
~~~~~~~~~~~~~
@@ -766,15 +763,13 @@ list items of a particular model class which have a given tag::
766763

767764
from django.conf.urls.defaults import *
768765

769-
from tagging.views import tagged_object_list
766+
from tagging.views import TaggedObjectList
770767

771768
from shop.apps.products.models import Widget
772769

773770
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),
778773
name='widget_tag_detail'),
779774
)
780775

@@ -783,13 +778,10 @@ perform filtering of the objects which are listed::
783778

784779
from myapp.models import People
785780

786-
from tagging.views import tagged_object_list
781+
from tagging.views import TaggedObjectList
787782

788-
def tagged_people(request, country_code, tag):
783+
class TaggedPeopleFilteredList(TaggedObjectList):
789784
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-
793785

794786
Template tags
795787
=============

0 commit comments

Comments
 (0)