2017-08-19 38 views
0

是否可以在Django Rest Framework文檔中關閉Description列?正如你在下面的截圖中看到的那樣,有一列Description。很明顯,usernamepassword的含義是什麼,所以我不需要添加更多信息,但空單元看起來不太好。我只想爲此方法關閉它,因爲例如在其他人中我想要說明。任何想法我怎麼能做到這一點? enter image description here如何關閉Django Rest Framework文檔中的描述列?

回答

0

目前沒有簡單的方法可以做到這一點,因爲'描述'列是在模板級設置的。看到這個template

爲了能夠做到這一點,你需要定製rest_framework /文檔/ link.html一個更好的方式,也許有一個模板標籤在這裏檢查自定義標誌:

{% elif link.fields|with_location:'form' %} 
<h4>Request Body</h4> 
<p>The request body should be a <code>"{{ link.encoding }}"</code> encoded object, containing the following&nbsp;items.</p> 
<table class="parameters table table-bordered table-striped"> 
    <thead> 
     <tr><th>Parameter</th><th>Description</th></tr> 
    </thead> 
    <tbody> 
     {% for field in link.fields|with_location:'form' %} 
     <tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <span class="label label-warning">required</span>{% endif %}</td><td>{% if field.schema.description %}{{ field.schema.description }}{% endif %}</td></tr> 
     {% endfor %} 
    </tbody> 
</table> 
{% endif %} 

但我認爲這是太多的考慮只是爲了刪除該列。