How do I use CreateView to add two items at once?

From the polls app, I understand how to add multiple items at once this in the admin panel for input, but I am struggling to find a way to do this through CreateView.

Basically, I want the user to be able to use the addingredients page to add more than one ingredient at once the same way it functions on the admin page of the polls app with adding additional choices.

Should I be looking at building a form for input to add this type of functionality? I’m new to Django and fairly new to programming in general, so I would appreciate any help on this, thanks!

Here is my view:

class addingredients(CreateView):
    model = Ingredient
    template_name = 'recipeBook/addingredients.html'
    fields = '__all__'
    extra_context = {
        'recipe_list': Recipe.objects.all()
    }

    def get_success_url(self):
        return reverse('recipeBook:recipe_details', kwargs={'pk': self.object.recipe.pk})

Here is my model:

class Ingredient(models.Model):
    UNIT_CHOICES = [
        ('TB', 'tablespoons'),
        ('TS', 'teaspoons'),
        ('OZ', 'ounces'),
        ('FO', 'fluid ounces'),
        ('CP', 'cups'),
        ('QT', 'quarts'),
        ('PT', 'pints'),
        ('GL', 'gallons'),
        ('LB', 'pounds'),
        ('ML', 'milliliters'),
        ('GR', 'grams'),
        ('KG', 'kilograms'),
        ('LI', 'liters'),
        ('UN', 'units')
    ]
    name = models.CharField(max_length=50)
    recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
    quantity = models.FloatField(default=0, blank=False)
    units = models.CharField(max_length=2, choices=UNIT_CHOICES, default='UN')

    def __str__(self):
        return self.name

Here is my Template:

{% extends 'recipeBook/base.html' %}

{% block title %}Add Ingredients{% endblock title %}


{% block content %} 
<h1>Step 1: Recipe Details</h1>

<form action="" method ="post">
  {% csrf_token %}
  <table>
    {{ form.as_table }}
  </table>
  <input type="submit" value="Add">
</form>
{% endblock content %}

Django provides formsets for when you want to create multiple instances of the same form for the same model on a page.

Note: Personally, I consider formsets to be one of the most difficult parts of Django to wrap my head around.

They work - extremely well - but it took me a long time to begin to get comfortable with them.

It’s very easy to make mistakes and not always easy to find the source of the mistake - especially if you’re adding the facility to add new rows on a page. (Doing so requires some JavaScript on the browser side.)

There are lots of discussion topics here that talk about formsets - including some with code people have written, so resources are available to help you learn.