Trying to add new app but templates are a mess #3843
-
I've created a new app and added it to the project folder. Weirdly, generic views (ListView) expect templates to be in a different folder than normal views (View).
My settings:
Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I will try to answer the 3 questions that were asked: 1 - How to create a new django app to cookiecuter-django based project:1 - create the 2 - How to explicitly customize the template used by django views that inherit from TemplateResponseMixin:For the
from django.views import generic
from my_project.my_app.models import MyModel
class MyModelBaseViewMixin:
model = MyModel
class MyModelListView(MyModelBaseViewMixin, generic.ListView):
template_name = 'my_app/item_list.html'
class MyModelDetailView(MyModelBaseViewMixin, generic.DetailView):
template_name = 'my_app/item_detail.html'
3 - How to customize the template used by django admin viewsif the problem is related to Django Admin integration, please customize the path to the correct template via the Custom template options of Django Admin: https://docs.djangoproject.com/en/4.0/ref/contrib/admin/#custom-template-options |
Beta Was this translation helpful? Give feedback.
I will try to answer the 3 questions that were asked:
1 - How to create a new django app to cookiecuter-django based project:
1 - create the
<name-of-the-app>
app with python manage.py startapp2 - move
<name-of-the-app>
directory to<project_slug>
directory3 - edit
<project_slug>/<name-of-the-app>/apps.py
andchange
name = "<name-of-the-app>"
toname = "<project_slug>.<name-of-the-app>"
4 - add
"<project_slug>.<name-of-the-app>.apps.<NameOfTheAppConfigClass>",
on yourLOCAL_APPS
onconfig/settings/base.py
2 - How to explicitly customize the template used by django views that inherit from TemplateResponseMixin:
For the
ListView/DetailView
problem, it would probably be nice if you had it …