title: How to manually attach a form field to manytomany model field in django?
body: <p>So this is my function in view:</p>
  
  <pre><code>def create_recipe(request):
      if request.method == 'POST':
             form = RecipeForm(request.POST)
             if form.is_valid():
                 current_user = request.user
                 data = form.cleaned_data
                 recipe_data=Recipe.objects.create(user=current_user, recipebase_id=data['recipebase_id'], title=data['title'], instructions=data['instructions'])
                 recipe_data.save()
                 return HttpResponseRedirect(reverse('create_recipe'))
             else:
                 messages.error(request, "Error")
      return render(request, 'create_recipe.html', {'form': RecipeForm })
  </code></pre>
  
  <p>and here is my form:</p>
  
  <pre><code>  class RecipeForm(forms.ModelForm):
  
          class Meta:
              model = Recipe
              fields = ('recipebase_id', 'title
  
  ', 'instructions')
  </code></pre>
  
  <p>and here is my model:</p>
  
  <pre><code>class Recipe(models.Model):
  
      user = models.ForeignKey('auth.User')
      recipebase_id = models.ManyToManyField(Recipebase)
      title = models.CharField(max_length=500)
      instructions = models.CharField(max_length=500)
      def __str__(self):
          return self.title
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>&lt;form action="/create_recipe/" method="post"&gt;
  {% csrf_token  %}
  
  
       &lt;div class="form-group"&gt;
            &lt;label for="{{ form.recipebase_id.label }}" class="form-control" &gt;
          &lt;select id="id_{{ form.recipebase_id.name }}" name="{{ form.recipebase_id.name }}"&gt;
      {% for value, title in form.recipebase_id.field.choices %}
  
              &lt;option value="{{ value }}"&gt;{{ title }}&lt;/option&gt;
  
          {% endfor %}
  
            &lt;/select&gt;
      &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
  &lt;label for="{{ form.title.label }}"&gt;{{ form.title.label }}:&lt;/label&gt;
  &lt;input type="{{ form.title.type }}" name="{{ form.title.name }}" max_length="500" class="form-control" id="{{ form.title.id }}"&gt;
  &lt;/div&gt;
  
  &lt;div class="form-group"&gt;
  &lt;label for="{{ form.instructions.label }}"&gt;{{ form.instructions.label }}:&lt;/label&gt;
  &lt;input type="{{ form.instructions.type }}" name="{{ form.instructions.name }}" max_length="500" class="form-control" id="{{ form.instructions.id }}"&gt;
  &lt;/div&gt;
  
  
       &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I submit the form, it throws recipebase_id is an invalid argument as:
  'recipebase_id' is an invalid keyword argument for this function</p>
  
  <p>It is understandable that it is a manytomany field so it doesnt quite fit like normal text field but I dont really understand which way to put it. Any suggestions?</p>