Changes between Initial Version and Version 1 of Ticket #31729


Ignore:
Timestamp:
Jun 20, 2020, 12:38:23 PM (4 years ago)
Author:
Mariusz Felisiak
Comment:

template_name is not necessary in this example, the inferred template will be "myapp/article_archive.html" that's why it's mentioned in docs. See note in "Generic views of objects" docs.

"Built-in class-based views API" docs is advanced docs and we shouldn't assume templates localization here (e.g. by changing to myapp/templates/myapp/article_archive.html,) that's why using an inferred template names is IMO the best option.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31729

    • Property Component UncategorizedDocumentation
    • Property Resolutioninvalid
    • Property Status newclosed
    • Property Summary The documentation for ArchiveIndexView is not clear for new developersThe documentation for ArchiveIndexView is not clear for new developers.
  • Ticket #31729 – Description

    initial v1  
     1{{{
    12path('archive/',
    23         ArchiveIndexView.as_view(model=Article, date_field="pub_date"),
    34         name="article_archive"),
    4 
     5}}}
    56where the only mentioned parameters are model and pub_date, and the name for the template. But using this above code does lead to an error saying template not found. Where the main problem is we are supposed to
    6 
     7{{{
    78path('archive/',
    89         ArchiveIndexView.as_view(model=Article, date_field="pub_date", template_name="article_archive.html"),
    910         ),
    10 
     11}}}
    1112mention the template_name as paramter for the as_view function. I know it might be silly to just look into the class and find the attribute "template_name" but for new comers trying to implement this might think they made a mistake somewhere else since the path was taking in the name of the template.
    1213So please do mention in the documentation
Back to Top