I need to create a manytomany field that has some options and then next to each option there is an extra field
My models:
class Subject(models.Model):
name = models.CharField(max_length=30)
duration = models.IntegerField()
price = models.IntegerField()
class Student(models.Model):
firstname = models.CharField(max_length=30)
lastname = models.CharField(max_length=30)
subject = models.ManyToManyField(Subject,through="StudentSubject")
class StudentSubject(models.Model)
student = models.ForeignKey(Student,on_delete=models.CASCADE)
subject = models.ForeignKey(Subject,on_delete=models.CASCADE)
discount = models.IntegerField()
I used the intermediate model StudentSubject(this contains the extra field) but I'm not sure how I should render this in a template I want to do something like this:
Math DiscountField1
Physics DiscountField2
CompSci DiscountField3