简体   繁体   English

Django REST:自定义样式

[英]Django REST: custom styling

Got attuned to work on Django project that used Django Rest Framework. 熟悉使用Django Rest Framework的Django项目。 Current GUI uses default styling. 当前GUI使用默认样式。

I would like to re-style it. 我想重新设计它。

There is an article describing re-styling: http://www.django-rest-framework.org/topics/browsable-api/ 有一篇描述重新造型的文章: http//www.django-rest-framework.org/topics/browsable-api/

However I don't understand where to add rest_framework folder with the api.html . 但是我不明白的地方添加rest_framework文件夹与api.html My existing project doesn't contain any folder related to REST. 我现有的项目不包含任何与REST相关的文件夹。

"To customize the default style, create a template called rest_framework/api.html that extends from rest_framework/base.html" “要自定义默认样式,请创建一个名为rest_framework / api.html的模板,该模板从rest_framework / base.html扩展”

Where to put rest_framework ? 在哪里放置rest_framework

It's up to you, every template dir will overwrite the default one. 这取决于你,每个模板目录都会覆盖默认模板。

I would recommend to use 我建议使用

/yourapp/yourapp/templates/rest_framework / yourapp / yourapp /模板/ rest_framework

as you probably want to use your template for the whole app. 因为您可能希望将模板用于整个应用程序。

I have found out, that putting rest_framework into /templates/ folder does the trick. 我发现,将rest_framework放入/templates/文件夹就可以了。

So the full path is: /templates/rest_framework/api.html . 所以完整的路径是: /templates/rest_framework/api.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM