2016-09-18 02:29:00 +03:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Character(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
2019-06-11 06:54:30 +03:00
|
|
|
ship = models.ForeignKey(
|
|
|
|
"Ship",
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
blank=True,
|
|
|
|
null=True,
|
|
|
|
related_name="characters",
|
|
|
|
)
|
2016-09-18 02:29:00 +03:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Faction(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
2017-12-05 23:01:52 +03:00
|
|
|
hero = models.ForeignKey(Character, on_delete=models.CASCADE)
|
2016-09-18 02:29:00 +03:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class Ship(models.Model):
|
2024-01-29 18:13:01 +03:00
|
|
|
class Meta:
|
|
|
|
ordering = ["pk"]
|
|
|
|
|
2016-09-18 02:29:00 +03:00
|
|
|
name = models.CharField(max_length=50)
|
2019-06-11 06:54:30 +03:00
|
|
|
faction = models.ForeignKey(Faction, on_delete=models.CASCADE, related_name="ships")
|
2016-09-18 02:29:00 +03:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|