Add Duck model skeleton
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| from django.db import models | ||||
| from django.contrib.auth.models import User | ||||
| from django.utils import timezone | ||||
|  | ||||
| class Species(models.Model): | ||||
|     """Model to hold the Ducks’ species""" | ||||
| @@ -26,3 +27,23 @@ class Competence(models.Model): | ||||
|  | ||||
|     def __str__(self): | ||||
|         return self.name | ||||
|  | ||||
| class Duck(models.Model): | ||||
|     """Model to hold Duck data""" | ||||
|  | ||||
|     name = models.CharField(max_length = 80, null = True, blank = True) | ||||
|     color = models.CharField(max_length = 6) | ||||
|     species = models.ForeignKey(Species) | ||||
|     location = models.ForeignKey(Location) | ||||
|     donated_by = models.ForeignKey(User) | ||||
|     donated_at = models.DateTimeField(default = timezone.now) | ||||
|     adopted_by = models.ForeignKey(User, related_name = 'adopted_ducks', null = True) | ||||
|     adopted_at = models.DateTimeField(null = True) | ||||
|     on_holiday_since = models.DateTimeField(null = True) | ||||
|     on_holiday_until = models.DateTimeField(null = True) | ||||
|  | ||||
|     def __str__(self): | ||||
|         if self.name == None or self.name == '': | ||||
|             return 'Unnamed :(' | ||||
|  | ||||
|         return self.name | ||||
|   | ||||
		Reference in New Issue
	
	Block a user