Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are naming rules of templates in django class based views

When using class-based views, many of them have default rule to automatically search a template so we don't need to specify it every time we use a class-based view.

But I can't find any article writes about how default naming is done.

What are the rules to define default template name?

like image 963
Bigair Avatar asked Mar 07 '23 01:03

Bigair


2 Answers

You can give template name as model_viewtype.html

Example: if model name is Abcd

  • for ListView: abcd_list.html
  • for CreateView: abcd_form.html
  • for DetailView: abcd_detail.html

And if you still face issues, the debugger will suggest you.

like image 106
Astik Anand Avatar answered Apr 06 '23 23:04

Astik Anand


Well if you don't create template, debugger is telling you which template you need to create. So if you want try it one by one. Otherwise use template_name = 'example.html'

like image 37
Goran Avatar answered Apr 06 '23 22:04

Goran