Skip to content

Commit b896f73

Browse files
authored
add bootstrap example (#72)
1 parent 340121c commit b896f73

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{# object_confirm_delete.html - Delete confirmation template #}
2+
{% extends "base.html" %}
3+
4+
{% block content %}
5+
<div class="row justify-content-center">
6+
<div class="col-12 col-md-8 col-lg-6">
7+
<div class="card">
8+
<div class="card-body">
9+
<h1 class="h3 mb-4">Are you sure you want to delete following {{ object_verbose_name }}?</h1>
10+
11+
<p class="text-danger mb-4">{{ object }}</p>
12+
13+
<form method="post">
14+
{% csrf_token %}
15+
{{ form }}
16+
<div class="d-grid">
17+
<button type="submit" class="btn btn-danger">Delete</button>
18+
</div>
19+
</form>
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
{% endblock %}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{# object_detail.html - Detail view template #}
2+
{% extends "base.html" %}
3+
{% load neapolitan %}
4+
5+
{% block content %}
6+
<h1 class="h3 mb-4">{{ object }}</h1>
7+
{% object_detail object view.fields %}
8+
{% endblock %}
9+
10+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{# object_form.html - Create/Edit form template #}
2+
{% extends "base.html" %}
3+
{% load crispy_forms_tags %}
4+
5+
{% block content %}
6+
<div class="row justify-content-center">
7+
<div class="col-12 col-md-8 col-lg-6">
8+
<h1 class="h3 mb-4">
9+
{% if object %}Edit {{ object_verbose_name }}{% else %}Create {{ object_verbose_name }}{% endif %}
10+
</h1>
11+
12+
<div class="card">
13+
<div class="card-body">
14+
<form method="post">
15+
{% csrf_token %}
16+
{{ form|crispy }}
17+
<div class="d-grid">
18+
<button type="submit" class="btn btn-primary">Save</button>
19+
</div>
20+
</form>
21+
</div>
22+
</div>
23+
</div>
24+
</div>
25+
{% endblock %}
26+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{# object_list.html - Main list template #}
2+
{% extends "base.html" %}
3+
{% load neapolitan %}
4+
5+
{% block content %}
6+
<div class="d-flex align-items-center mb-4">
7+
<div class="flex-grow-1">
8+
<h1 class="h3">{{ object_verbose_name_plural|capfirst }}</h1>
9+
</div>
10+
{% if create_view_url %}
11+
<div class="ms-auto">
12+
<a href="{{ create_view_url }}" class="btn btn-primary">
13+
<i class="bi bi-plus-lg"></i>
14+
Add a new {{ object_verbose_name }}
15+
</a>
16+
</div>
17+
{% endif %}
18+
</div>
19+
20+
{% if object_list %}
21+
{% object_list object_list view %}
22+
{% else %}
23+
<div class="alert alert-info">
24+
<p class="mb-0">There are no {{ object_verbose_name_plural }}. Create one now?</p>
25+
</div>
26+
{% endif %}
27+
{% endblock %}
28+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{# partial/detail.html - Detail partial template #}
2+
<div class="card">
3+
<div class="card-body">
4+
<dl class="row mb-0">
5+
{% for field, val in object %}
6+
<dt class="col-sm-3">{{ field|capfirst }}:</dt>
7+
<dd class="col-sm-9">{{ val }}</dd>
8+
{% endfor %}
9+
</dl>
10+
</div>
11+
</div>
12+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{# partial/list.html - List partial template #}
2+
<div class="table-responsive">
3+
<table class="table table-striped table-hover">
4+
<thead>
5+
<tr>
6+
{% for header in headers %}
7+
<th>{{ header|capfirst }}</th>
8+
{% endfor %}
9+
<th class="text-end">Actions</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
{% for object in object_list %}
14+
<tr>
15+
{% for field in object.fields %}
16+
<td>{{ field }}</td>
17+
{% endfor %}
18+
<td class="text-end">
19+
{{ object.actions }}
20+
</td>
21+
</tr>
22+
{% endfor %}
23+
</tbody>
24+
</table>
25+
</div>
26+

0 commit comments

Comments
 (0)