Fix semantic error in new Django 3 Choices.

This commit is contained in:
Casper V. Kristensen 2020-09-17 18:16:17 +02:00
parent fb6fcc3307
commit 1c72c58781
Signed by: caspervk
GPG key ID: 289CA03790535054
2 changed files with 10 additions and 10 deletions

View file

@ -57,7 +57,7 @@ class RaidResponse(models.Model):
) )
role = models.PositiveSmallIntegerField( role = models.PositiveSmallIntegerField(
choices=Character.Roles.choices, choices=Character.Role.choices,
blank=True, blank=True,
null=True null=True
) )
@ -83,15 +83,15 @@ class RaidResponse(models.Model):
choices=Status.choices choices=Status.choices
) )
class Groups(models.IntegerChoices): class Group(models.IntegerChoices):
GROUP_1 = 1 GROUP_1 = 1
GROUP_2 = 2 GROUP_2 = 2
GROUP_3 = 3 GROUP_3 = 3
GROUP_4 = 4 GROUP_4 = 4
group = models.PositiveSmallIntegerField( group = models.PositiveSmallIntegerField(
choices=Groups.choices, choices=Group.choices,
default=Groups.GROUP_1 default=Group.GROUP_1
) )
attendance = models.DecimalField( attendance = models.DecimalField(

View file

@ -68,8 +68,8 @@ class User(AbstractUser):
self.main = Character.objects.create( self.main = Character.objects.create(
user=None, user=None,
name=self.username, name=self.username,
klass=Character.WARRIOR, klass=Character.Klass.WARRIOR,
role=Character.DAMAGE role=Character.Role.DAMAGE
) )
self.main.save() self.main.save()
user = super().save(*args, **kwargs) user = super().save(*args, **kwargs)
@ -93,7 +93,7 @@ class Character(models.Model):
unique=True unique=True
) )
class Klasses(models.IntegerChoices): class Klass(models.IntegerChoices):
DRUID = 1 DRUID = 1
HUNTER = 2 HUNTER = 2
MAGE = 3 MAGE = 3
@ -106,16 +106,16 @@ class Character(models.Model):
klass = models.PositiveSmallIntegerField( klass = models.PositiveSmallIntegerField(
"class", "class",
choices=Klasses.choices choices=Klass.choices
) )
class Roles(models.IntegerChoices): class Role(models.IntegerChoices):
TANK = 1 TANK = 1
HEALER = 2 HEALER = 2
DAMAGE = 3 DAMAGE = 3
role = models.PositiveSmallIntegerField( role = models.PositiveSmallIntegerField(
choices=Roles.choices choices=Role.choices
) )
class Meta: class Meta: