title: Django how to show many2many extra fields in a form?
body: <p>here are my models.py:</p>
  <pre class="lang-py prettyprint-override"><code>
      class EssentialOil(models.Model):
      name = models.fields.CharField(max_length=120, verbose_name=&quot;Nom&quot;)
      latin_name = models.fields.CharField(max_length=120, verbose_name=&quot;Nom latin&quot;)
      abbreviation = models.fields.CharField(max_length=8, verbose_name=&quot;Abbréviation&quot;)
      image = models.fields.CharField(default=None, null=True, blank=True, max_length=255, verbose_name=&quot;Photo&quot;)
      administrationmodes = models.ManyToManyField('AdministrationMode', through=&quot;EssentialOil_AdministrationMode&quot;,
                                                   verbose_name=&quot;Mode d'administration&quot;)
      components = models.ManyToManyField('Component', through=&quot;EssentialOil_AdministrationMode&quot;,
                                          verbose_name=&quot;Composants&quot;)
      warnings = models.ManyToManyField('warning', through=&quot;EssentialOil_AdministrationMode&quot;,
                                        verbose_name=&quot;Points d'attention&quot;)
      properties = models.ManyToManyField('property', through=&quot;EssentialOil_AdministrationMode&quot;,
                                          verbose_name=&quot;Propriétés&quot;)
      uses = models.ManyToManyField('use', through=&quot;EssentialOil_AdministrationMode&quot;,
                                    verbose_name=&quot;Utilisations thérapeuthiques&quot;)
  
      class Meta:
          ordering = ['name']
  
      def __str__(self):
          return self.name
  
  class AdministrationMode(models.Model):
      mode = models.fields.CharField(max_length=100, verbose_name=&quot;Mode&quot;)
      description = models.fields.CharField(max_length=2000, verbose_name=&quot;Description&quot;)
      warning = models.fields.TextField(max_length=2000, default=&quot;Aucun&quot;, verbose_name=&quot;Point d'attention&quot;)
  
      eo = models.ManyToManyField(EssentialOil, through='EssentialOil_AdministrationMode', blank=True,
                                  verbose_name=&quot;H.E. concernées&quot;)
  
      class Meta:
          ordering = ['mode']
  
      def __str__(self):
          return self.mode
  
  class EssentialOil_AdministrationMode(models.Model):
      class Efficiency(models.IntegerChoices):
          RARE = 1
          PARFOIS = 2
          SOUVENT = 3
          IDEAL = 4
  
      eo = models.ForeignKey(&quot;EssentialOil&quot;, null=True, on_delete=models.CASCADE)
      am = models.ForeignKey(&quot;AdministrationMode&quot;, null=True, on_delete=models.CASCADE)
      co = models.ForeignKey(&quot;Component&quot;, null=True, on_delete=models.CASCADE)
      pr = models.ForeignKey(&quot;Property&quot;, null=True, on_delete=models.CASCADE)
      us = models.ForeignKey(&quot;Use&quot;, null=True, on_delete=models.CASCADE)
      wa = models.ForeignKey(&quot;Warning&quot;, null=True, on_delete=models.CASCADE)
  
      efficiency = models.IntegerField(Efficiency.choices)
  
      class Meta:
          unique_together = [['eo', 'am']]
  </code></pre>
  <p>My forms.py:</p>
  <pre class="lang-py prettyprint-override"><code>
      from django import forms
  from django.forms import ModelForm
  from .models import EssentialOil, AdministrationMode, Component, Warning, Property, Use
  
  
  class CreateEssentialOil(ModelForm):
      class Meta:
          model = EssentialOil
          fields = &quot;__all__&quot;
  
      administrationmodes = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                           queryset=AdministrationMode.objects.all(),
                                                           label=&quot;Mode d'administration&quot;)
      components = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                           queryset=Component.objects.all(),
                                                           label=&quot;Composants&quot;)
      warnings = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                           queryset=Warning.objects.all(),
                                                           label=&quot;Points d'attention&quot;)
      properties = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                           queryset=Property.objects.all(),
                                                           label=&quot;Propriétés&quot;)
      uses = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                           queryset=Use.objects.all(),
                                                           label=&quot;Utilisations thérapeutiques&quot;)
  </code></pre>
  <p>My views.py :</p>
  <pre class="lang-py prettyprint-override"><code>
  from django.forms import inlineformset_factory
  from django.http import HttpResponse, HttpResponseRedirect
  from django.shortcuts import render
  from .models import EssentialOil, AdministrationMode, Component, Warning, Property, Use, EssentialOil_AdministrationMode
  from .forms import CreateEssentialOil, CreateAdministrationMode, \
      CreateComponent, CreateWarning, CreateProperty, CreateUse
  
  
  def create_essentialoil(request):
      form = CreateEssentialOil()
      if request.method == 'POST':
          form = CreateEssentialOil(request.POST)
          if form.is_valid():
              print(request.POST)
              form.save()
              return HttpResponseRedirect('/essentialoil/essentialoils')
          else:
              print(request.POST)
      # if a GET (or any other method) we'll create a blank form
      else:
          form = CreateEssentialOil()
  
      return render(request, 'essentialoil_app/forms/essentialoil_form.html', {'form': form})
  </code></pre>
  <p>When I create an EssentialOil, I would like to be able to select multiple AdministrationMode AND give an efficiency value for that AdministrationMode.</p>
  <p>Now, I'm able to create the EssentialOil and select the AdministrationMode, but I don't know how to make the &quot;effeciency&quot; field visible in my form as in the picture below
  <a href="https://i.stack.imgur.com/gjNxE.jpg" rel="nofollow noreferrer">How i would like to see it in my form</a></p>
  <p>I hope to find some help here.
  Thanks for reading.
  JP</p>