Skip to content

Commit 91a6567

Browse files
committed
template update with table, Based on 'DESC_TABLE' condition to render the fields in table
1 parent b4558a0 commit 91a6567

File tree

1 file changed

+43
-0
lines changed
  • rest_framework_docs/templates/rest_framework_docs

1 file changed

+43
-0
lines changed

rest_framework_docs/templates/rest_framework_docs/home.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
table {
6+
font-family: arial, sans-serif;
7+
border-collapse: collapse;
8+
width: 100%;
9+
}
10+
11+
td, th {
12+
border: 1px solid #dddddd;
13+
text-align: left;
14+
padding: 8px;
15+
}
16+
17+
tr:nth-child(even) {
18+
background-color: #ECF0F1;
19+
}
20+
</style>
21+
</head>
122
{% extends "rest_framework_docs/docs.html" %}
223
{% load drfdocs_filters %}
324

@@ -65,8 +86,29 @@ <h4 class="panel-title title">
6586
{% endif %}
6687

6788
{% if endpoint.fields %}
89+
{% if desc_table %}
90+
<p class="fields-desc">Fields details:</p>
91+
<table>
92+
<tr>
93+
<th> Field Name </th>
94+
<th> Field Type </th>
95+
<th> Max Length </th>
96+
<th> Is Required </th>
97+
</tr>
98+
{% for field in endpoint.fields %}
99+
<tr>
100+
<td> {{ field.name }} </td>
101+
<td> {{ field.type }} </td>
102+
<td> {{ field.max_length }} </td>
103+
<td> {{ field.required }} </td>
104+
</tr>
105+
{% endfor %}
106+
</table>
107+
{% else %}
108+
68109
<p class="fields-desc">Fields:</p>
69110
{%include "rest_framework_docs/components/fields_list.html" with fields=endpoint.fields %}
111+
{% endif %}
70112
{% elif not endpoint.errors %}
71113
<p>No fields.</p>
72114
{% endif %}
@@ -99,3 +141,4 @@ <h4 class="modal-title">Live API Endpoints <span class="label label-info">Beta</
99141
</div>
100142

101143
{% endblock %}
144+
</html>

0 commit comments

Comments
 (0)