0
how can I insert a list of my database into the select form?
html template.
<div class="form-group">
<label for="{{ form.id_departamento }}">Nome departamento</label>
<select name="{{ form.id_departamento }}" required="" class="form-control" id="{{ form.id_departamento }}" multiple="">
<option value="">------</option>
<option value="{{ form.id_departamento }}">{{ form.id_departamento }}</option>
</select>
</div>
py.models
class Funcionario(models.Model):
nome = models.CharField(max_length=100, help_text='Nome completo do funcionário')
funcao = models.CharField(max_length=100, help_text='Função na empresa')
user = models.OneToOneField(User, on_delete=models.PROTECT, related_name='funcionario')
departamentos = models.ManyToManyField(Departamento, related_name='funcionario')
empresa = models.ForeignKey(
Empresa, on_delete=models.PROTECT, null=True, blank=True)
I didn’t get the class part right, I create a Forms.py file and include the code in it?
– Luis Marra