Ticket #26115: models.py

File models.py, 747 bytes (added by Kevin Mann, 9 years ago)

Three models as described in bug report.

Line 
1from django.db import models
2
3# Create your models here.
4class Employee(models.Model):
5 name = models.CharField(max_length=20, unique=True)
6
7 def __str__(self):
8 return self.name
9
10 def current_title(self):
11 return self.employeetitle_set.latest('start_date')
12 current_title.admin_order_field = 'employeetitle__title__name'
13
14class EmployeeTitle(models.Model):
15 employee = models.ForeignKey('Employee')
16 title = models.ForeignKey('Title')
17 start_date = models.DateField()
18 end_date = models.DateField(null=True, blank=True)
19
20 def __str__(self):
21 return self.title.name
22
23class Title(models.Model):
24 name = models.CharField(max_length=20, unique=True)
25
26 def __str__(self):
27 return self.name
Back to Top