@@ -8,11 +8,14 @@ class Employee(models.Model):
8
8
lastName = models .CharField (max_length = 30 )
9
9
salary = models .FloatField ()
10
10
email = models .CharField (max_length = 254 )
11
-
12
11
#anotehr way to display this a certain way in admin...
13
12
#def __str__(self):
14
13
# return self.email
15
14
15
+ class Project (models .Model ):
16
+ projectName = models .CharField (max_length = 50 )
17
+ #many to many reference field
18
+ programmers = models .ManyToManyField (Employee )
16
19
17
20
class Passenger (models .Model ):
18
21
first = models .CharField (max_length = 30 , default = '' , validators = [validators .MinLengthValidator (2 , 'must be 2 characters or more.' )])
@@ -24,4 +27,17 @@ class Passenger(models.Model):
24
27
points = models .FloatField (default = 0 )
25
28
26
29
def __str__ (self ):
27
- return str (self .id ) + " | " + str (self .first ) + " " + str (self .last ) + " ---> " + str (self .points )
30
+ return str (self .id ) + " | " + str (self .first ) + " " + str (self .last ) + " ---> " + str (self .points )
31
+
32
+ class ContactPhone (models .Model ):
33
+ type = models .CharField (max_length = 10 )
34
+ number = models .CharField (max_length = 10 )
35
+ # on deletions of an employee - the contactPhone should also be deleted.
36
+ # ManytoOne relationship via ForeignKey
37
+ owner = models .ForeignKey (Employee ,on_delete = models .CASCADE , null = False )
38
+
39
+ class Identification (models .Model ):
40
+ type = models .CharField (max_length = 10 )
41
+ number = models .CharField (max_length = 10 )
42
+ # on deletions of an employee - the contactPhone should also be deleted.
43
+ employee = models .OneToOneField (Employee ,on_delete = models .CASCADE )
0 commit comments