36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from django.db import models
|
|
|
|
|
|
class Dinosaur(models.Model):
|
|
ERA_CHOICES = [
|
|
('triassic', 'Triassic'),
|
|
('jurassic', 'Jurassic'),
|
|
('cretaceous', 'Cretaceous'),
|
|
]
|
|
|
|
DIET_CHOICES = [
|
|
('herbivore', 'Herbivore'),
|
|
('carnivore', 'Carnivore'),
|
|
('omnivore', 'Omnivore'),
|
|
]
|
|
|
|
name = models.CharField(max_length=120)
|
|
era = models.CharField(max_length=32, choices=ERA_CHOICES, default='jurassic')
|
|
diet = models.CharField(max_length=32, choices=DIET_CHOICES, default='herbivore')
|
|
description = models.TextField(blank=True)
|
|
image = models.ImageField(upload_to='dinosaurs/', blank=True, null=True)
|
|
|
|
# Top-trump style stats (0-100)
|
|
speed = models.PositiveSmallIntegerField(default=50)
|
|
weight = models.PositiveSmallIntegerField(default=50)
|
|
intelligence = models.PositiveSmallIntegerField(default=50)
|
|
height = models.PositiveSmallIntegerField(default=50)
|
|
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at', 'name']
|
|
|
|
def __str__(self):
|
|
return self.name
|