Skip to content

Commit

Permalink
Render form fields in Bootstrap 5 (#5)
Browse files Browse the repository at this point in the history
* Render fields in Bootstrap 5
* Explain what is happening in CHANGELOG and docs
* Rework test files
* Fix or disable tests
  • Loading branch information
dyve committed Mar 18, 2021
1 parent 05fb942 commit d88bfe2
Show file tree
Hide file tree
Showing 22 changed files with 840 additions and 805 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## [0.0.1] - In development

- Do not abuse title element for help text.
- Remove `InlineFieldRenderer`.
- Simplify size parameters, only accept "sm", "md", "lg".
- Use `bootstrap_alert` in `bootstrap_messages`.
- Document approach to form rendering in `docs/forms.rst`.
- Use .readthedocs.yml to configure Read the Docs.
- Place AUTHORS in text file, remove from documentation.
- Drop all jQuery stuff since Bootstrap 5 does not need jQuery.
- Place AUTHORS in text file, remove authors from documentation.
- Drop all jQuery support since Bootstrap 5 does not need jQuery.
- Use `django_bootstrap5` as name for Python package.
- Started `django-bootstrap5` based on `django-bootstrap4`.
- Thanks everybody that contributed to `django-bootstrap4` and earlier versions!
3 changes: 3 additions & 0 deletions docs/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ Bootstrap 5 offers Input groups to combine fields and add-ons (both before and a
1. We must support separate rendering of labels, fields, help texts and errors so that users can build their own input groups.
2. We should offer support for add-ons (before and after) as part of `bootstrap_field`.
3. We could add support in form, field or widget definition to define add-ons in Python code.

Note: input-group needs has-validation
https://github.com/twbs/bootstrap/blob/6b3254536bac263c39e3a536c3c13945210d91b2/site/content/docs/5.0/migration.md
4 changes: 2 additions & 2 deletions example/templates/app/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<hr>

{% bootstrap_pagination lines url="/pagination?page=1&flop=flip" extra="q=foo" size="small" %}
{% bootstrap_pagination lines url="/pagination?page=1&flop=flip" extra="q=foo" size="sm" %}

{% bootstrap_pagination lines url="/pagination?page=1" size="large" %}
{% bootstrap_pagination lines url="/pagination?page=1" size="lg" %}

{% endblock %}
5 changes: 3 additions & 2 deletions src/django_bootstrap5/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from .html import render_tag
from .text import text_value

FORM_GROUP_CLASS = "form-group"
WRAPPER_CLASS = ""
WRAPPER_TAG = "div"


def render_formset(formset, **kwargs):
Expand Down Expand Up @@ -134,7 +135,7 @@ def render_field_and_label(field, label, field_class="", label_for=None, label_c
return html


def render_form_group(content, css_class=FORM_GROUP_CLASS):
def render_form_group(content, css_class=WRAPPER_CLASS):
"""Render a Bootstrap form group."""
return '<div class="{css_class}">{content}</div>'.format(css_class=css_class, content=content)

Expand Down

0 comments on commit d88bfe2

Please sign in to comment.