Question

I have 2 models in django, and im also using ModelForm, my question is the second model have a froreignkey of the 1, and i want to have one page when generating the form. It's possible, how to link the two forms in one page.

Class Event(models.Model):
  id = models.AutoField(primary_key=True)
  name = models.CharField()

class Date(models.Model):
   id = models.AutoField(primary_key=True)
   start = models.DateTimeField()
   end = models.DateTimeField()
   event = models.ForeignKey("Event")

I also have

class EventForm(ModelForm)
Class Date(ModelForm)

What i want is to create the event in one page in my templates.

Thanks.

Was it helpful?

Solution

If you want to have this on the Django Admin, then you need to use inline models.
If you plan to create your own form (using ModelForms), then you need to use inline formets.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top