Add Duck model skeleton

This commit is contained in:
Gergely Polonkai 2014-12-22 14:25:55 +01:00 committed by Gergely Polonkai
parent 52e3550427
commit d7feab58fe
1 changed files with 21 additions and 0 deletions

View File

@ -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