Added __str__ to models in Assignment and Homepage

parent 0629b161
...@@ -9,6 +9,9 @@ class Course(models.Model): ...@@ -9,6 +9,9 @@ class Course(models.Model):
@property @property
def course_info(self): def course_info(self):
return '{} {} {}'.format(self.course_code, self.course_title, self.section) return '{} {} {}'.format(self.course_code, self.course_title, self.section)
def __str__(self):
return '{} {}'.format(self.course, self.section)
class Assignment(models.Model): class Assignment(models.Model):
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
...@@ -29,4 +32,7 @@ class Assignment(models.Model): ...@@ -29,4 +32,7 @@ class Assignment(models.Model):
assignment += '<br>Passing Score: {}'.format(self.passing_score) assignment += '<br>Passing Score: {}'.format(self.passing_score)
assignment += '<br>Course/Section: {}<br>'.format(self.course.course_info) assignment += '<br>Course/Section: {}<br>'.format(self.course.course_info)
return assignment return assignment
\ No newline at end of file
def __str__(self):
return '{} - {}'.format(self.name, self.course.__str__)
\ No newline at end of file
No preview for this file type
...@@ -8,6 +8,9 @@ class Department(models.Model): ...@@ -8,6 +8,9 @@ class Department(models.Model):
@property @property
def dept_info(self): def dept_info(self):
return '{}, {}'.format(self.dept_name, self.home_unit) return '{}, {}'.format(self.dept_name, self.home_unit)
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model): class WidgetUser(models.Model):
first_name = models.CharField(max_length=50) first_name = models.CharField(max_length=50)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment