在我自己的应用程序中使用 Django 管理外观
我喜欢 django admin 非常简单但仍然非常优雅的外观和感觉,我想知道是否有一种方法可以将它应用到我自己的应用程序中。
(我想我在某处读过类似的内容,但现在我无法再次找到该页面。)
(编辑:我正在寻找的是一种通过扩展模板、导入模块或类似的东西来自动执行此操作的方法,而不是只需复制并粘贴 css 和 javascript 代码)
I like the very simple but still really elegant look and feel of the django admin and I was wondering if there is a way to apply it to my own application.
(I think that I've read something like that somewhere, but now I cannot find the page again.)
(edited: what I am looking for is a way to do it automatically by extending templates, importing modules, or something similar, not just copy&paste the css and javascript code)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定要获取管理站点的所有外观和外观吗? 感觉??
我认为您需要自定义一些内容,例如页眉页脚等。
为此,只需从
并将其保留在
只需更改您想要自定义的任何 HTML 并保持原样(如 CSS 和 Javascript),并继续在应用程序的其他模板中扩展此模板。 您的视图应该提供渲染所需的内容(从源代码中查看任何 django 视图),并且您将拥有管理员外观和功能的所有内容。 感觉有了。 您可以通过以相同的方式扩展 base_site.html 来完成更多操作。
Are you sure you want to take every bit of admin-site's look & feel??
I think you would need to customize some, as in header footer etc.
To do that, just copy base.html from
and keep it in
Just change whatever HTML you want to customize and keep rest as it is (like CSS and Javascript) and keep on extending this template in other templates of your application. Your view should provide what it needs to render (take a look at any django view from source) and you'll have everything what admin look & feel had. More you can do by extending base_site.html in same manner.
通常是一个很好的起点,但请查看 contrib/admin/templates 中的模板并复制其中的一些技术。
is usually a good place to start but do look at the templates in contrib/admin/templates and copy some of the techniques there.