Django override app templates




















Answered By: cutteeth. Answered By: Adam Starrh. Answered By: Stavinsky. Answered By: user Answered By: Bryan.

Share this: Facebook Tweet WhatsApp. Related posts: How to create a custom Estimator in PySpark. Leave a Reply Cancel reply Your email address will not be published.

Combined with block. Offline Django 4. Django is a registered trademark of the Django Software Foundation. Django The web framework for perfectionists with deadlines.

Could not load branches. Could not load tags. Latest commit. Git stats 38 commits. Failed to load latest commit information. View code. In the Django wiki, Simon Willison presents a trick to achieve the "self-extending template" effect.

I've misread the question, my original answer applies only to the admin app, which has a built-in template extension mechanism. For other app that lacks such mechanism, I would just fork the original templates instead of fiddling with custom template loaders like the chosen answer advises.

If you are worried about forking, you can also implement an extension mechanism and contribute back to the original project if you think it is worth. Straight from the fine manual : Because of the modular design of the admin templates, it is usually neither necessary nor advisable to replace an entire template. It is almost always better to override only the section of the template which you need to change. To continue the example above, we want to add a new link next to the History tool for the Page model.

And that's it! You could also do this as a symlink. At the top of it, put the following:. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 11 years, 2 months ago. Active 1 year, 1 month ago. Viewed 24k times. Improve this question. Bernhard Vallant Bernhard Vallant 45k 17 17 gold badges silver badges bronze badges.



0コメント

  • 1000 / 1000