django-crispy-forms / crispy-tailwind

A Tailwind template pack for django-crispy-forms
MIT License
331 stars 56 forks source link

many to many field when being rendered from model form its being rendered without mutiple in html #97

Closed ym500 closed 3 years ago

ym500 commented 3 years ago

i think there is bug when rendering many to many field from modelform is being rendered without mutiple in HTML.

smithdc1 commented 3 years ago

Thanks for the report.

Please can provide a small reproducible example?

ym500 commented 3 years ago

download the simple project, run it

Just Go go to 127.0.0.1:8000/simple

testin_tailwind.zip

blasferna commented 3 years ago

I have the same issue.

If I want to render a form from the model Django.contrib.auth.models.Group the ManyToManyField does not have the multiple attribute.

The model:


class Group(models.Model):
    name = models.CharField(_('name'), max_length=150, unique=True)
    permissions = models.ManyToManyField(
        Permission,
        verbose_name=_('permissions'),
        blank=True,
    )

The form renders a Select field instead of Select with the Multiple attribute image

The template:

{% extends 'base.html' %}
{% load tailwind_filters %}

{% block content %}
<div class="w-80 mx-auto mt-5">
<form method="post">
    {% csrf_token %}
    {{ form|crispy }}
    <input class="px-3 py-2 hover:bg-gray-300 rounded" type="submit" value="Submit">
</form>
<div>
{% endblock %}

If I remove the filter | crispy I get the field correctly. image

ym500 commented 3 years ago

Thanks @blasferna i will close the issue now