1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-11-24 22:57:32 +00:00
Altessimo/idols/models.py

31 lines
988 B
Python
Raw Normal View History

2021-07-09 18:25:07 +00:00
from django.db import models
# Create your models here.
# Create your models here.
class IdolManager(models.Manager):
def comma_to_qs(self, idols_str):
final_ids = []
if idols_str:
for idol in idols_str.split(','):
obj, created = self.get_or_create(romanized_name=idol.strip())
final_ids.append(obj.id)
qs = self.get_queryset().filter(id__in=final_ids).distinct()
return qs
return self.none()
class Idol(models.Model):
branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT)
name = models.CharField(max_length=255, blank=True)
romanized_name = models.CharField(max_length=255)
voice_actor_name = models.CharField(max_length=255, blank=True)
romanized_voice_actor_name = models.CharField(max_length=255, blank=True)
objects = IdolManager()
def __str__(self):
return self.romanized_name+" (CV: "+self.romanized_voice_actor_name+")"