python - Django: reusable templates: extend from base.html -
what reusable way "extends" method in django templates?
i have seen often:
{% extends 'base.html' %}
unfortunately not work me. ordering of template loader loads template different app first.
i have default django project , application created scratch django1.8.
what should do:
- use different name 'my_base.html'
- alter ordering of template loader
- other solution?
the easy way solve problem namespace templates. create application , inside application directory (where have default views.py
) create templates directory, , inside directory create subdirectory name of application.
imagine have project myproj
, app called registration, have:
. ├── manage.py ├── myproj │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── registration ├── admin.py ├── __init__.py ├── migrations │ └── __init__.py ├── models.py ├── templates │ └── registration │ └── base.html ├── tests.py └── views.py
now if have application template called base.html
, can load specific template need {% extends 'registration/base.html' %}
Comments
Post a Comment