many to many data, form widget

hello so i have these two models:

class Medicine(models.Model):
    medicine = models.CharField(max_length=150)

class Condition(models.Model):
    patient = models.ForeignKey(
        settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="conditions"
    conditions = models.ForeignKey(
        ConditionInfo, on_delete=models.CASCADE, related_name="conditions"
    severity = models.CharField(max_length=100, blank=True, null=True)
    medicines = models.ManyToManyField(
        Medicine, related_name="conditions", null=True, blank=True

and this form:

class ConditionForm(ModelForm):
    class Meta:
        model = Condition
        exclude = ("patient",)

so my question is
right now when i put this form in a html page for my users to fill in
the many to many field doesn’t allow users to input new data
they can only choose from pre-existing data

how can i set so users can do both choosing from existing data or input new ones if they want to

Regarding “new data”, are you talking about adding instances of Medicine?

If so, you’ll want to do that on a different form. That could be a different page, or you could do it using a modal box like the admin does. (That’s done using the green “+” sign in the forms.)

yes that is what i’m asking about, thank you

but could you link me to this model box?
i don’t seem to be able to find it
i would be grateful
thank you

If you configure your application for the Django Admin, and look at an instance of your Condition model, you will see a many-to-many select box widget for selecting instances of Medicine. Next to that widget, you will see a green “+” sign that will bring up a pop-up modal box to allow you to enter a new instance of Medicine.

If you don’t have your app configured for the admin, you can see the same thing when using the admin to explore the User model and the Group instances related to a User.