from django.conf.urls.defaults import patterns, url
from django.views.generic import list_detail

from sphinxdoc import models
from sphinxdoc.views import ProjectSearchView


project_info = {
    'queryset': models.Project.objects.all().order_by('name'),
    'template_object_name': 'project',
}

urlpatterns = patterns('sphinxdoc.views',
    url(
        r'^$',
        list_detail.object_list,
        project_info,
    ),
    url(
        r'^(?P<slug>[\w-]+)/search/$',
        ProjectSearchView(),
        name='doc-search',
    ),
    # These URLs have to be without the / at the end so that relative links in
    # static HTML files work correctly and that browsers know how to name files
    # for download
    url(
        r'^(?P<slug>[\w-]+)/(?P<type_>_images|_static|_downloads|_source)/' + \
                r'(?P<path>.+)$',
        'sphinx_serve',
    ),
    url(
        r'^(?P<slug>[\w-]+)/_objects/$',
        'objects_inventory',
        name='objects-inv',
    ),
    url(
        r'^(?P<slug>[\w-]+)/$',
        'documentation',
        {'path': ''},
        name='doc-index',
    ),
    url(
        r'^(?P<slug>[\w-]+)/(?P<path>.+)/$',
        'documentation',
        name='doc-detail',
    ),
)

from django.conf.urls.defaults import patterns, url
from django.views.generic.list import ListView

from sphinxdoc import models
from sphinxdoc.views import ProjectSearchView


urlpatterns = patterns('sphinxdoc.views',
    url(
        r'^$',
        ListView.as_view(queryset=models.Project.objects.all().order_by('name'))
    ),
    url(
        r'^(?P<slug>[\w-]+)/search/$',
        ProjectSearchView(),
        name='doc-search',
    ),
    # These URLs have to be without the / at the end so that relative links in
    # static HTML files work correctly and that browsers know how to name files
    # for download
    url(
        r'^(?P<slug>[\w-]+)/(?P<type_>_images|_static|_downloads|_source)/' + \
                r'(?P<path>.+)$',
        'sphinx_serve',
    ),
    url(
        r'^(?P<slug>[\w-]+)/_objects/$',
        'objects_inventory',
        name='objects-inv',
    ),
    url(
        r'^(?P<slug>[\w-]+)/$',
        'documentation',
        {'path': ''},
        name='doc-index',
    ),
    url(
        r'^(?P<slug>[\w-]+)/(?P<path>.+)/$',
        'documentation',
        name='doc-detail',
    ),
)

Change function-based generic view to class-based.
Change function-based generic view to class-based.

As per their deprecation policy, Django 1.5 removed function-based
generic views.

  from django.conf.urls.defaults import patterns, url
- from django.views.generic import list_detail
+ from django.views.generic.list import ListView
  
  from sphinxdoc import models
  from sphinxdoc.views import ProjectSearchView
  
  
- project_info = {
-     'queryset': models.Project.objects.all().order_by('name'),
-     'template_object_name': 'project',
- }
- 
  urlpatterns = patterns('sphinxdoc.views',
      url(
          r'^$',
+         ListView.as_view(queryset=models.Project.objects.all().order_by('name'))
-         list_detail.object_list,
-         project_info,
      ),
      url(
          r'^(?P<slug>[\w-]+)/search/$',
          ProjectSearchView(),
          name='doc-search',
      ),
      # These URLs have to be without the / at the end so that relative links in
      # static HTML files work correctly and that browsers know how to name files
      # for download
      url(
          r'^(?P<slug>[\w-]+)/(?P<type_>_images|_static|_downloads|_source)/' + \
                  r'(?P<path>.+)$',
          'sphinx_serve',
      ),
      url(
          r'^(?P<slug>[\w-]+)/_objects/$',
          'objects_inventory',
          name='objects-inv',
      ),
      url(
          r'^(?P<slug>[\w-]+)/$',
          'documentation',
          {'path': ''},
          name='doc-index',
      ),
      url(
          r'^(?P<slug>[\w-]+)/(?P<path>.+)/$',
          'documentation',
          name='doc-detail',
      ),
  )
  
Change function-based generic view to class-based.
## Code Before:
from django.conf.urls.defaults import patterns, url
from django.views.generic import list_detail

from sphinxdoc import models
from sphinxdoc.views import ProjectSearchView


project_info = {
    'queryset': models.Project.objects.all().order_by('name'),
    'template_object_name': 'project',
}

urlpatterns = patterns('sphinxdoc.views',
    url(
        r'^$',
        list_detail.object_list,
        project_info,
    ),
    url(
        r'^(?P<slug>[\w-]+)/search/$',
        ProjectSearchView(),
        name='doc-search',
    ),
    # These URLs have to be without the / at the end so that relative links in
    # static HTML files work correctly and that browsers know how to name files
    # for download
    url(
        r'^(?P<slug>[\w-]+)/(?P<type_>_images|_static|_downloads|_source)/' + \
                r'(?P<path>.+)$',
        'sphinx_serve',
    ),
    url(
        r'^(?P<slug>[\w-]+)/_objects/$',
        'objects_inventory',
        name='objects-inv',
    ),
    url(
        r'^(?P<slug>[\w-]+)/$',
        'documentation',
        {'path': ''},
        name='doc-index',
    ),
    url(
        r'^(?P<slug>[\w-]+)/(?P<path>.+)/$',
        'documentation',
        name='doc-detail',
    ),
)

## Instruction:
Change function-based generic view to class-based.
## Code After:
from django.conf.urls.defaults import patterns, url
from django.views.generic.list import ListView

from sphinxdoc import models
from sphinxdoc.views import ProjectSearchView


urlpatterns = patterns('sphinxdoc.views',
    url(
        r'^$',
        ListView.as_view(queryset=models.Project.objects.all().order_by('name'))
    ),
    url(
        r'^(?P<slug>[\w-]+)/search/$',
        ProjectSearchView(),
        name='doc-search',
    ),
    # These URLs have to be without the / at the end so that relative links in
    # static HTML files work correctly and that browsers know how to name files
    # for download
    url(
        r'^(?P<slug>[\w-]+)/(?P<type_>_images|_static|_downloads|_source)/' + \
                r'(?P<path>.+)$',
        'sphinx_serve',
    ),
    url(
        r'^(?P<slug>[\w-]+)/_objects/$',
        'objects_inventory',
        name='objects-inv',
    ),
    url(
        r'^(?P<slug>[\w-]+)/$',
        'documentation',
        {'path': ''},
        name='doc-index',
    ),
    url(
        r'^(?P<slug>[\w-]+)/(?P<path>.+)/$',
        'documentation',
        name='doc-detail',
    ),
)
