The code link you have attached is using one of Django's generic views CreateView
. And Django follows some conventions to decide what template to use for the view. In the case of CreateView
Django tries to find the template with the name of model used by your view in lowercase and the default template_name_suffix
which is _form
. In your case your model name is
model = Upload
So Django tries to find a template with the name upload_form.html
. And if you wish to change the default template_name
you can always override it like this.
class UploadView(CreateView):
model = Upload
template_name = 'upload.html'
Besides this, you can also override the get_template_names
method as well, it is sometimes useful when you have to conditionally decide the name of the template i.e you are planning to use a different HTML file for different users.
Here is the Django docs link and another very useful ref about CBVs.