Opened 5 years ago

Closed 5 years ago

#31729 closed Uncategorized (invalid)

The documentation for ArchiveIndexView is not clear for new developers.

Reported by: Kenneth Prabakaran Owned by: nobody
Component: Documentation Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Mariusz Felisiak)

path('archive/',
         ArchiveIndexView.as_view(model=Article, date_field="pub_date"),
         name="article_archive"),

where 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

path('archive/',
         ArchiveIndexView.as_view(model=Article, date_field="pub_date", template_name="article_archive.html"),
         ),

mention 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.
So please do mention in the documentation

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Component: UncategorizedDocumentation
Description: modified (diff)
Resolution: invalid
Status: newclosed
Summary: The documentation for ArchiveIndexView is not clear for new developersThe documentation for ArchiveIndexView is not clear for new developers.

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.

Note: See TracTickets for help on using tickets.
Back to Top