Is it possible somehow by default to choose all the choices within a select multiple generated by ManyToManyField in Django?
All new items that are added should have all choices selected upfront in the view (also when adding new items of AnotherEntity).
class AnotherEntity(models.Model):
name = models.CharField()
class SomeEntity(models.Model):
anotherEntity = models.ManyToManyField(AnotherEntity)
In the example above i wish to have all choices in anotherEntity selected in all new items.
Just inherit
SelectMultiplewidget and override: 1)render_optionto render all selected; 2)render_optionscontrol where we have render all selected and where as default.Then set widget to your field in form: