Hello, I would like to know how I can do and store in a field multiple checkboxes for my model. I tried the following:
models.py:
n_dentes = (
('18', '18'),
('17', '17'),
('16', '16'),
('15', '15'),
('14', '14'),
('13', '13'),
('12', '12'),
('11', '11'),
('21', '21'),
('22', '22'),
('23', '23'),
('24', '24'),
('25', '25'),
('26', '26'),
('27', '27'),
('28', '28'),
('48', '48'),
('47', '47'),
('46', '46'),
('45', '45'),
('44', '44'),
('43', '43'),
('42', '42'),
('41', '41'),
('31', '31'),
('32', '32'),
('33', '33'),
('34', '34'),
('35', '35'),
('36', '36'),
('37', '37'),
('38', '38'),
)
class pregao(models.Model):
dente = MultiSelectField(_('Dente '), choices=n_dentes, default=' ', max_length=100)
cor = models.CharField(_('Cor '), default=' ', max_length=5)
material = models.CharField(_('Material '), choices=materiais_choices, max_length=100, default=' ')
extra = models.TextField(_('Observações '), max_length=500, null=True, blank=True)
data = models.DateField(default=datetime.date.today)
preco = models.FloatField(_('Preço '), default='0')
class Meta:
verbose_name = 'Pregão'
verbose_name_plural = 'Pregões'
page.html
{% for value, text in form.providers.field.choices %}
<div class="ui slider checkbox">
<input id="id_providers_{{ forloop.counter0 }}" name="{{ form.providers.name }}" type="checkbox" value="{{ value }}"{% if value in checked_providers %} checked="checked"{% endif %}>
<label style="width:8px;">{{ text }}</label>
</div>
{% endfor %}
But when rendering it all goes out of the way and I still have to go through a library, is there any other more efficient way for me to do that?