You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The templates for this app are located in the root ccdb5_ui/templates level and thus referred to with no subdirectories when rendering, e.g. template_name = 'standalone-base.html'.
This works as long as all template names are guaranteed to be unique across all apps in a Django project, but could cause conflicts if, say, another app also has a standalone_base.html in its root templates directory. Prefixing all template names with ccdb- might work but has to be done consistently.
The Django convention seems to be to place templates under subdirectories named for the app, e.g. ccdb5-ui/templates/ccdb5-ui/main.html. At first this might feel duplicative but it makes the view code clearer, especially if these templates are ever referred to from another project, e.g. 'template_name = 'ccdb5-ui/main.hml.
Now we might be able to get away with putting our templates directly in polls/templates (rather than creating another polls subdirectory), but it would actually be a bad idea. Django will choose the first template it finds whose name matches, and if you had a template with the same name in a different application, Django would be unable to distinguish between them. We need to be able to point Django at the right one, and the easiest way to ensure this is by namespacing them. That is, by putting those templates inside another directory named for the application itself.
Current behavior
Templates for this app live under ccdb5-ui/templates.
Expected behavior
Templates for this app live under ccdb5-ui/templates/ccdb5-ui.
The text was updated successfully, but these errors were encountered:
The templates for this app are located in the root
ccdb5_ui/templates
level and thus referred to with no subdirectories when rendering, e.g.template_name = 'standalone-base.html'
.This works as long as all template names are guaranteed to be unique across all apps in a Django project, but could cause conflicts if, say, another app also has a
standalone_base.html
in its roottemplates
directory. Prefixing all template names withccdb-
might work but has to be done consistently.The Django convention seems to be to place templates under subdirectories named for the app, e.g.
ccdb5-ui/templates/ccdb5-ui/main.html
. At first this might feel duplicative but it makes the view code clearer, especially if these templates are ever referred to from another project, e.g.'template_name = 'ccdb5-ui/main.hml
.From the Django tutorial:
Current behavior
Templates for this app live under
ccdb5-ui/templates
.Expected behavior
Templates for this app live under
ccdb5-ui/templates/ccdb5-ui
.The text was updated successfully, but these errors were encountered: