My timesheet.html will have the variables of ID, name, startDate and endDate. I wish to display all these fields in a table in list_timesheet.html. But i have a problem of displaying the same ID and same name several times with different start and end date. Does anyone has any idea on what i should do on my models.py ? Right now i can only submit timesheet with the same ID and name ONCE, because of the foreign key problem,when i try to submit a timesheet with the SAME ID and name but DIFFERENT start and end date, it will show error saying "student ID and student Name already exist".
models.py
#consists of all the details in the timesheet
class Timesheet(models.Model):
studentID = models.CharField("Student ID", max_length=8, primary_key=True, default="")
studentName = models.CharField("Student Name", max_length=500, default="")
startDate = models.DateField("Start Date", max_length=8)
endDate = models.DateField("End Date", max_length=8)
def __str__(self):
return self.studentID
#consists of all the details of the timesheet under 'View Timesheets'
class LTimesheet(models.Model):
timesheet = models.OneToManyField(Timesheet, on_delete=models.CASCADE, primary_key=True)
status = models.CharField("Status", max_length=100)