1
0
Fork 0
mirror of https://github.com/Findus23/RPGnotes.git synced 2024-09-19 15:43:45 +02:00
RPGnotes/locations/models.py

27 lines
771 B
Python
Raw Normal View History

2021-09-06 20:34:43 +02:00
from django.db import models
2021-09-15 16:51:43 +02:00
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
2021-09-15 16:51:43 +02:00
from tree_queries.fields import TreeNodeForeignKey
from tree_queries.models import TreeNode
from common.models import NameSlugModel, DescriptionModel, HistoryModel
class Location(TreeNode, NameSlugModel, DescriptionModel, HistoryModel):
parent = TreeNodeForeignKey(
"self",
blank=True,
null=True,
on_delete=models.CASCADE,
verbose_name=_("Part of"),
2021-09-15 16:51:43 +02:00
related_name="children",
)
2021-09-06 20:34:43 +02:00
2021-09-15 16:51:43 +02:00
class Meta:
ordering = ["name"]
verbose_name = _("Location")
verbose_name_plural = _("Locations")
2021-09-06 20:34:43 +02:00
2021-09-15 16:51:43 +02:00
def get_absolute_url(self):
return reverse('locationdetail', args=[self.slug])