1đź‘Ť
âś…
You could hack this together with some javascript code to handle the selection to copy the student and lesson details from the drop down boxes into the form but then why not just fix the model in the first place.
class lesson_student(models.Model):
lesson = models.ForeignKey(Lesson)
student = models.ForeignKey(Student)
Now, not only do you have details about their codes… you have the full models to available. You also will not have anything else left to do in terms of your form since the ModelForm
will take care of that.
i have problem in my list ….. in student or lesson list i have “Student Object” & “Lesson Object” instead of names
Thats because you haven’t provided a string representation for your models.
I.e
class student(models.Model):
First_Name = models.CharField(max_length=100,null=True)
Last_Name = models.CharField(max_length=100,null=True)
STNO = models.CharField(max_length=10,null=True)
def __str__(self):
return "{0} {1}".format(self.First_Name, self.Last_Name)
👤Sayse
Source:stackexchange.com