Giter Site home page Giter Site logo

django-bootstrap5's People

Contributors

akx avatar attakei avatar clokep avatar dakrauth avatar dependabot[bot] avatar dyve avatar emmceemoore avatar flipperpa avatar frewsxcv avatar github-actions[bot] avatar jieter avatar jonashaag avatar juancarlospaco avatar lstaniszewski avatar luzfcb avatar markush avatar metajiji avatar nikolas avatar notsqrt avatar oliver-ni avatar ookami-kb avatar owais avatar sandertuit avatar sedrubal avatar stewartbiggs avatar tyvik avatar xi avatar xrmx avatar xsurfer avatar yaleman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-bootstrap5's Issues

forms.ImageField adding `<br>` between the label and input fields.

Tested using Django 2.2 on Windows and Ubuntu 20.04

Using regular Django fields works just fine, but a bootstrap_field like {% bootstrap_field form.image_upload show_label=False %} introduces a <br> tag between the label and the input fields. It seems to happen both with the FileInput / ClearableFileInput widgets as far as I can tell.

form

Fix floating labels

Make sure we know which input types support floating labels. Currently we check for not matching an input type, which will give problems with range, date, time, et cetera.

Rendering form with exclude is broken

Example:

{% bootstrap_form form exclude="ignore_field" %}

field renderer returns empty (unsafe) string when encountering the ignored field. When concatenated with safe text, the resulting string becomes unsafe and renders escaped html string into template instead rendering the form.

Remove buttons tag

The buttons tag was introduced to align automatically generated buttons with the fields in the form.

In Bootstrap 5, this magic is no longer necessary. Also, the output of the tag was hard to predict. It's better to let users style their own buttons, with the option to use the bootstrap_button tag.

Floating labels are not a layout

Floating labels do not affect the layout of the entire form, just how certain input types are rendered. We should not use the layout setting for this.

Injection in render_tag

render_tag should not try to form attributes:

> render_tag('div', {'class': '{tag}'})
expected: <div class="{tag}"></div>
actual: <div class="div"></div>

> render_tag('div', {'class': '{foo}'})
expected: <div class="{foo}"></div>
actual: KeyError

Switch to CalVer

With regular updates, dependancies on Bootstrap versions and issues whether or not something is a breaking change, CalVer is a better fit for versioning. For example, YY.0M.MICRO.

CheckboxInput does not display "this field is required" error

Update this method to fix it.

    def get_checkbox_classes(self):
        """Return CSS classes for checkbox."""
        classes = ["form-check"]
        if self.checkbox_style == "switch":
            classes.append("form-switch")
        if self.checkbox_layout == "inline":
            classes.append("form-check-inline")
        if self.field_errors:
            classes.append(self.error_css_class)
        elif self.field.form.is_bound:
            classes.append(self.success_css_class)
        return merge_css_classes(*classes)

if it was me, I would add a method like this to make getting valid/invalid easier:

    def get_valid(self):
        if self.field_errors:
            return self.error_css_class
        elif self.field.form.is_bound:
            return self.success_css_class
        return None # or return '' for concatenation

Please support form-outline layout variant

I'm using Material Design Bootstrap (MDB) and there is very stylish form field layout variant in use.
If you would allow layout='outline' and the use the 'form-outline' class instead of 'form-floating' it would work fine.

The problem is, that the label has to be rendered after the input widget (like as in floating layout). So there is no easy workaround for this.

Bildschirmfoto 2021-08-05 um 10 55 11

Bildschirmfoto 2021-08-05 um 10 55 41

Update docstrings

Check docstrings, especially public functions, methods and classes.

wrapper_class does not override mb-3

In django-bootstrap4, bootstrap_field field form_group_class='foo' will use a form group class of foo.

In django-bootstrap5, bootstrap_field field wrapper_class='foo' will use a wrapper class of foo mb-3.

This breaks cases where you need to remove the default margin.

A possible workaround is to use layout='inline', but that adds unrelated styling which might cause other issues.

How to extend django_bootstrap5 default templates

As a user of Conda environments on Windows 10,

I want to extend C:\Users\Test\Programming\anaconda3\envs\Django\lib\site-packages\django_bootstrap5\src\django_bootstrap5\templates\django_bootstrap5\bootstrap5.html

by a template inside some app of my Django project; eg C:\Users\Test\Programming\team\project\app\templates\app\base.html.

How can I do it?

Exception Type: NoReverseMatch
Exception Value: Reverse for 'home' not found. 'home' is not a valid view function or pattern name.
Exception Location: C:\Users\Test\Programming\anaconda3\envs\Django\lib\site-packages\django\urls\resolvers.py, line 694, in _reverse_with_prefix
Error during template rendering
In template C:\Users\Test\Programming\anaconda3\envs\Django\lib\site-packages\django_bootstrap5\templates\django_bootstrap5\bootstrap5.html, error at line 11

CheckboxMultipleInput does not render form-invalid

<input class="form-check-input #ADD ERROR HERE"

on each form-check-input the error should be displayed

I'll update this if I figure out where this code gets generated.

It's super hack-y but this works added to the end of renderers.py

html = format_html(
            '<{tag} class="{wrapper_classes}">{label}{field_with_help_and_errors}</{tag}>',
            tag=WRAPPER_TAG,
            wrapper_classes=self.get_wrapper_classes(),
            label=label,
            field_with_help_and_errors=field_with_help_and_errors,
        )
        if isinstance(self.widget,CheckboxSelectMultiple):
            addition = None
            if self.field_errors:
                addition = self.error_css_class
            elif self.field.form.is_bound:
                addition = self.success_css_class
            if addition:
                html = html.replace('<input class="form-check-input','<input class="form-check-input {addition}'.format(addition=addition))
                html = format_html(html)
        return html

Support for Material Design Bootstrap (MDB)

I just started using django_bootstrap5 in my projects where I'm using Material Design Bootstrap (MDB).
Unfortunately they use a different 'prefix' for (at least the event names). For example they use 'data-mdb-dismiss' instead of the 'data-bs-dismiss'. This has the effect, that for example the closing button on alerts does not work.

As the rendering of alerts is done in a function and not with a template, I have no chance to change it.
I don't know what the best solution for this problem is. But one could be to make this prefix ('mdb' or 'bs' or ..) configurable.

For sure there are be more places in the source code where MDB will have effects.

Upgrade Bootstrap to 5.0.1

https://getbootstrap.com/docs/5.0/getting-started/download/#cdn-via-jsdelivr

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>

Use standard Exceptions

The BootstrapException classes have nu added value or function. Standard classes offer more clarity.

module 'django_bootstrap5.renderers' has no attribute 'InlineFieldRenderer'

Upon running the example server, and navigating to "form_inline" I got this error page:

module 'django_bootstrap5.renderers' has no attribute 'InlineFieldRenderer'

Request Method: GET
Request URL: http://127.0.0.1:8000/form_inline
Django Version: 3.1.7
Exception Type: AttributeError
Exception Value: module 'django_bootstrap5.renderers' has no attribute 'InlineFieldRenderer'
Exception Location: /Users/username/.pyenv/versions/3.9.1/lib/python3.9/site-packages/django_bootstrap5/core.py, line 72, in get_renderer
Python Executable: /Users/username/.pyenv/versions/3.9.1/bin/python
Python Version: 3.9.1
Python Path: ['/Users/username/django-bootstrap5/django_bootstrap5', '/Users/jdhemsath1/django-bootstrap5/example', '/Users/username/.pyenv/versions/3.9.1/lib/python39.zip', '/Users/jdhemsath1/.pyenv/versions/3.9.1/lib/python3.9', '/Users/username/.pyenv/versions/3.9.1/lib/python3.9/lib-dynload', '/Users/username/.pyenv/versions/3.9.1/lib/python3.9/site-packages']
Server time: Wed, 24 Mar 2021 00:53:53 +0100

I tried adding and deleting 'field_renderers': { 'default': 'django_bootstrap5.renderers.FieldRenderer', 'inline': 'django_bootstrap5.renderers.InlineFieldRenderer', }, to the settings.py file in the Example folder, with no change.

Looking at the source renderers.py it looks like there is no class for InlineFieldRenderer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.