Django 1.6.11
App structure looks like:
my_project/
|-- new_app/
|-- templates/
in my config:
TEMPLATE_ROOT = os.path.join(BASE_ROOT, 'templates/')
TEMPLATE_DIRS = (
TEMPLATE_ROOT,
)
INSTALLED_APPS = (
'django.contrib.admin',
...
'new_app',
)
I've also tried listing new_app
before contrib.admin
and that didn't help.
When I copy venv/django/contrib/admin/templates/admin/change_list.html
to my /templates/admin/new_app/change_list.html
I don't see my customizations show up.
my_project/
|-- new_app/
|-- templates/
|-- admin/
|-- new_app/
|-- change_list.html
When I move change_list.html up one level so it's under the admin path, the changes show up just fine:
my_project/
|-- new_app/
|-- templates/
|-- admin/
|-- change_list.html
|-- new_app/ (now an empty folder)
... but of course that would mean my changes are going to affect every admin page, not just for the app I'm trying to modify.
I've added this to the app's only model within admin.py:
class MyModelAdmin(reversion.VersionAdmin):
change_list_template = 'admin/new_app/change_list.html'
... this gives me some of what I need, but I also need change_list_results.html and there's no ModelAdmin override for that.
I'm following the documentation guide found at readthedocs in section 2.4.8 on page 31, but I don't seem to be having any luck.
To override these templates, you will need to have an admin folder in your templates folder. If you do not have a templates folder, you can create it in the main project folder. To do so, you will have to change the project's settings.py . Find the TEMPLATES section and modify accordingly.
The Django admin is a powerful built-in tool giving you the ability to create, update, and delete objects in your database using a web interface. You can customize the Django admin to do almost anything you want.
With APP_DIRS set to True , the template loader will look in the app's templates directory and find the templates.
The default templates used by the Django admin are located under the /django/contrib/admin/templates/ directory of your Django installation inside your operating system's or virtual env Python environment (e.g. <virtual_env_directory>/lib/python3. 5/site-packages/django/contrib/admin/templates/ ).
When several applications provide different versions of the same resource (template, static file, management command, translation), the application listed first in INSTALLED_APPS has precedence. See docs.
Change:
INSTALLED_APPS = (
'django.contrib.admin',
...
'new_app',
)
To:
INSTALLED_APPS = (
'new_app',
'django.contrib.admin',
...
)
Your templates in new_app
should now be found before the templates in contrib.admin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With