7

Am I correct in understanding that "from django.views.generic import list_detail" has been deprecated and/or removed from Django?

If so, what is the appropriate successor?

Thanks,

--

@Gareth, thanks.

I have a followup question to ask: how do you use a ListView to replace a list_detail.object_detail?

The present code, which has been changed only in the import, is:

from django.conf.urls.defaults import *
#from django.views.generic import list_detail
from django.views.generic.list import ListView

from announcements.models import Announcement
from announcements.views import *


announcement_detail_info = {
    "queryset": Announcement.objects.all(),
}

urlpatterns = patterns("",
    url(r"^(?P<object_id>\d+)/$", list_detail.object_detail,
        announcement_detail_info, name="announcement_detail"),
    url(r"^(?P<object_id>\d+)/hide/$", announcement_hide,
        name="announcement_hide"),
    url(r"^$", announcement_list, name="announcement_home"),
)

https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-display/#listview does not seem to suggest a single inline replacement for:

    url(r"^(?P<object_id>\d+)/$", list_detail.object_detail,
        announcement_detail_info, name="announcement_detail"),

If anything, it suggests an additional model be added, and that model be built on.

Is there a quick, inline replacement for the list_detail.object_detail call, or does it take more uprooting?

Thanks,

2
  • Breadcrumb remark: I made this post as part of a concerted effort to get a Pinax 0.7.3 social project to work with a more recent version of Pinax (for reasons beyond me, the social project in Pinax 1.0.0 is a bare stub, complete with lorem ipsum in the final page). It took me a lot of digging to get to Pinax 0.7.3 (there are innumerable places advertising a free Pinax 0.7.3 download, but I tried dozens and they all pointed to a pinaxproject.com (now) 404. Having found Pinax 0.7.3 and wanting to save other programmers the headache, I have made it available at JonathansCorner.com/pinax Mar 30, 2013 at 20:06
  • Just published an article about migrating from function-based generic views to class-based analogs in Django read the article Dec 18, 2013 at 10:49

2 Answers 2

10

django.views.generic.list_detail was deprecated in Django 1.3:

From Django 1.3, function-based generic views have been deprecated in favor of a class-based approach.

Use django.views.generic.list.ListView instead.

1
  • Thank you; could you look at my edited page above and tell me how I might approach this aspect of porting? Mar 25, 2013 at 21:36
8

After importing django.views.generic.list.ListView

You just need to change list_detail.object_detail to ListView.as_view()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.