Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:11:26+00:00 2026-06-16T11:11:26+00:00

My IDE (PyCharm) keeps reporting: Function-based generic views have been deprecated. I have the

  • 0

My IDE (PyCharm) keeps reporting: Function-based generic views have been deprecated.

I have the following statement in my import list:

from django.views.generic.list_detail import object_list

And my view looks like the following:

def category(request, id, slug=None):
    category = Category.objects.get(pk=id)

    books = Book.objects.filter(
        Q(status = 1) & Q(category=category)
    ).order_by('-id')

    s = Poet.objects.order_by('?')[:3]

    return object_list(
        request,
        template_name = 'books/categories/show.html',
        queryset = books,
        paginate_by = 99,
        extra_context = {
            'category': category,
            'suggestions': s,
            'bucket_name': config.BOOKS_BUCKET_NAME,
            }
    )

I found this in SO, but the docs seems overly complicated in this regard.

Any tips on how I can convert my code would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:11:27+00:00Added an answer on June 16, 2026 at 11:11 am

    You could try something like this

    from django.views.generic import ListView
    
    class CategoryView(ListView):
        template_name = 'books/categories/show.html'
        paginate_by = 99
    
        def get_queryset(self):
            self.category = Category.objects.get(pk=self.kwargs['id'])
    
            books = Book.objects.filter(
               Q(status = 1) & Q(category=self.category)
            ).order_by('-id')
    
            self.s = Poet.objects.order_by('?')[:3]
    
            return books
    
        def get_context_data(self, **kwargs):
            context = super(CategoryView, self).get_context_data(**kwargs)
            context['category'] = self.category
            context['suggestions'] = self.s
            return context
    

    This code is not tested, please report back if it’s working for you.
    Note that the book list will be available through the context variable ‘object_list’, if you want to give it a different name you can use the ‘context_object_name’ class member:

    class CategoryView(ListView):
        template_name = 'books/categories/show.html'
        context_object_name = 'books'
        ...
    

    and in your urls.py use the class-based view’s as_view() method

    url( r'your pattern', CategoryView.as_view(), name='whatever')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My python IDE PyCharm by defaults suggests to change the following line of python:
I am using the Python IDE PyCharm and something that is have by default
I know PyCharm is young IDE but id like to know if you guys
IDE = VS7 or 2002 Hi all, I have a really weird problem here.
My IDE has been working very well, until today. When I try to compile
In Scala IDE I get the following error about the class I am to
IDE - Visual Studio 2008, Visual C++ I have a custom class Class1 with
IDE: netbeans Playframework: v 1.2.4 from my app/controllers/application.java i call following public static void
I have used selenium IDE and created test cases. I have converted them to
When it comes to constructors, and assignments, and method calls, the PyCharm IDE is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.