Use django-bootstrap for forms

This commit is contained in:
Gabriel Augendre 2022-10-31 22:03:53 +01:00
parent 87ccc913f8
commit c08abc2685
8 changed files with 29 additions and 9 deletions

View file

@ -28,6 +28,7 @@
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/src/common/templates" />
<option value="$MODULE_DIR$/src/character/templates" />
</list>
</option>
</component>

17
poetry.lock generated
View file

@ -222,6 +222,17 @@ amazon_ses = ["boto3"]
dev = ["flake8", "sphinx", "sphinx-rtd-theme", "tox", "twine", "wheel"]
postal = ["cryptography"]
[[package]]
name = "django-bootstrap5"
version = "22.1"
description = "Bootstrap 5 for Django"
category = "main"
optional = false
python-versions = ">=3.7"
[package.dependencies]
Django = ">=3.2"
[[package]]
name = "django-browser-reload"
version = "1.6.0"
@ -956,7 +967,7 @@ h11 = ">=0.9.0,<1"
[metadata]
lock-version = "1.1"
python-versions = ">=3.10.0, <4"
content-hash = "2005841e057ea97d65b1582d1454765504d5146e98ffe5e2023e694ef093f6a4"
content-hash = "d112838252717a7085bcb8eb5b1893d98cb99d0e708791e5d4e2b0ada7341a9f"
[metadata.files]
ansicon = [
@ -1178,6 +1189,10 @@ django-anymail = [
{file = "django-anymail-8.6.tar.gz", hash = "sha256:783342d49dd07d68778b81dd12a94c86e1d217463a68a85450a0513fabe31345"},
{file = "django_anymail-8.6-py3-none-any.whl", hash = "sha256:49d83d7c16316ca86a624097496881d59b7d71b16bf1c5211cffa5b19ef98d0c"},
]
django-bootstrap5 = [
{file = "django-bootstrap5-22.1.tar.gz", hash = "sha256:70b51f020ef95a64780a0b5d5fdb1fade6e7b5e26c53355cc4f3648eca239cab"},
{file = "django_bootstrap5-22.1-py3-none-any.whl", hash = "sha256:cf3f257abf750f19e47eddc106066ddb182576185494965d1408eddcb3a7380b"},
]
django-browser-reload = [
{file = "django-browser-reload-1.6.0.tar.gz", hash = "sha256:9ca69c71796f53868bdc7421f120d147f7a64faa0d5d8c06970ba3f8061af63c"},
{file = "django_browser_reload-1.6.0-py3-none-any.whl", hash = "sha256:31b8b2d51e8faa5878f21e6b60b8f43e1123907c6e082e9e967962ba63958829"},

View file

@ -22,6 +22,7 @@ selenium = ">=4.5.0"
Markdown = ">=3.2"
django-registration = ">=3.3"
django-anymail = {extras = ["mailgun"], version = ">=8.6"}
django-bootstrap5 = ">=22.1"
[tool.poetry.dev-dependencies]
django-debug-toolbar = ">=3.2"

View file

@ -1,6 +1,6 @@
<div class="mt-3" id="notes">
<form>
<h4>
<h2>
Notes
<a hx-post="{% url "character:notes_change" pk=character.pk %}"
hx-target="#notes"
@ -9,7 +9,7 @@
>
<i class="fa-solid fa-save"></i> Save
</a>
</h4>
</h2>
{% csrf_token %}
<textarea class="form-control" name="notes" rows="10">{{ character.notes }}</textarea>
</form>

View file

@ -63,6 +63,7 @@ EXTERNAL_APPS = [
"django_linear_migrations",
"django_extensions",
"django_htmx",
"django_bootstrap5",
"django_cleanup.apps.CleanupConfig", # should be last: https://pypi.org/project/django-cleanup/
]
if DEBUG_TOOLBAR:

View file

@ -18,12 +18,11 @@
</style>
</head>
<body>
<div class="container-fluid">
<div class="container">
{% if user.is_authenticated %}
<a href="{% url "logout" %}">Déconnexion</a>
{% endif %}
{% block content %}
{% include "common/hello-random.html" %}
{% endblock %}
</div>

View file

@ -1,10 +1,11 @@
{% extends "common/base.html" %}
{% load django_bootstrap5 %}
{% block content %}
<h1>Inscription</h1>
<form action="{% url "django_registration_register" %}" method="post">
{{ form.as_p }}
{% csrf_token %}
<button type="submit" class="btn btn-primary">Submit</button>
{% bootstrap_form form %}
{% bootstrap_button button_type="submit" content="S'inscrire" %}
</form>
{% endblock %}

View file

@ -1,11 +1,13 @@
{% extends "common/base.html" %}
{% load django_bootstrap5 %}
{% block content %}
<h1>Connexion</h1>
<form action="{% url "login" %}" method="post">
{{ form.as_p }}
{% csrf_token %}
<button type="submit" class="btn btn-primary">Submit</button>
{% bootstrap_form form %}
{% bootstrap_button button_type="submit" content="Connexion" %}
<a href="{% url "django_registration_register" %}" class="btn btn-secondary">
Create account
</a>