Select multiple in Python and Django

Asked

Viewed 32 times

1

I have a class Lancamento and a class Plano de conta. Plano de conta is a secondary Launch key, ie I register account plans and when registering a launch I select an account plan.

For that, I did so

class Lancamento(models.Model):
    plano = models.ForeignKey(
        PlanoConta,
        related_name="plano",
        on_delete=models.SET_NULL,
        null=True,
        blank=True
    )

in class LancamentoForm in widgets did so:

'plano': forms.Select(attrs={'class': 'form-control'}),

That way I can select one account plan for each launch. But how do I choose multiples account plans for each launch?

By changing the forms.Select for forms.SelectMultiple when trying to select and send, I get the message Make a valid choice. Your choice is not one of the available.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.