Faced a strange. Here is a primitive CBV:

class PublicationList(ListView): model = Publication template_name = 'publications.html' paginate_by = 20 allow_empty = True 

Suppose there are 60 instances of the Publication model in the database. Then PublicationList should display 3 pages with data, and the fourth empty. That's just it on page 4 gives me a 404th error (EmptyPage: That page contains no results), ignoring the parameter allow_empty. Why? Am I missing something?

    1 answer 1

    You misunderstand the purpose of this attribute.

    allow_empty is made to handle the situation when your list is initially empty. If it is set to True, then you will see a page with no results. If False, then django will generate a standard error 404. No more difference. Take a look at the code

    A page with no results should return 404 anyway, this is correct