create initial models and mobile test for mojtaba eshaghi
This commit is contained in:
40
apps/livestock/models.py
Normal file
40
apps/livestock/models.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from apps.core.models import BaseModel
|
||||
from apps.herd import models as herd_models
|
||||
from apps.tag import models as tag_models
|
||||
from django.db import models
|
||||
|
||||
|
||||
class LiveStock(BaseModel):
|
||||
herd = models.ForeignKey(
|
||||
herd_models.Herd,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="live_stock_herd",
|
||||
null=True
|
||||
)
|
||||
tag = models.ForeignKey(
|
||||
tag_models.Tag,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='livestock_tag',
|
||||
null=True
|
||||
)
|
||||
types = (
|
||||
('L', 'Light'),
|
||||
('H', 'Heavy')
|
||||
)
|
||||
type = models.CharField(max_length=1, choices=types)
|
||||
species_type = (
|
||||
()
|
||||
)
|
||||
species = models.CharField(max_length=1, choices=species_type)
|
||||
birthdate = models.DateTimeField(null=True)
|
||||
gender_type = (
|
||||
(1, 'male'),
|
||||
(2, 'female')
|
||||
)
|
||||
gender = models.IntegerField(choices=gender_type, default=1)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.get_species_display()}-{self.get_type_display()}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(LiveStock, self).save(*args, **kwargs)
|
||||
Reference in New Issue
Block a user