1
I currently have this class with a field Choice, tried to leave by default "deufault=None" can it remains bringing the field filled with Royal Flush, if I move to another existing City he accepts, I’m doing something wrong?
class Sessao(models.Model):
MAO_DERROTA = (
('Royal Flush', 'Royal Flush'),
('Straight Flush', 'Straight Flush'),
('Quadra', 'Quadra'),
('Full House', 'Full House'),
('Flush', 'Flush'),
('Straight', 'Straight'),
('Trinca', 'Trinca'),
('Dois pares', 'Dois pares'),
('Um Par', 'Um Par'),
('Carta Alta', 'Carta Alta'),
)
data_ini_sessao = models.DateField(verbose_name='Data inicial da partida')
torneio = models.ForeignKey(Torneio, verbose_name='Torneio', on_delete=models.CASCADE)
buy_in = models.DecimalField(max_digits=10, decimal_places=2,verbose_name='Buy-in')
jogadores = models.IntegerField(verbose_name='Qtd jogadores')
premio = models.DecimalField(max_digits=10, decimal_places=2,verbose_name='Vlr Premio')
saldo = models.DecimalField(max_digits=10, decimal_places=2,verbose_name='Saldo da partida')
colocacao = models.IntegerField(verbose_name='Colocação')
data_fin_sessao = models.DateField(verbose_name='Data final da partida')
user = models.ForeignKey(User, on_delete=models.CASCADE)
tempo = models.IntegerField(verbose_name='Tempo')
comentario_sessao = models.TextField(blank=True)
mao_derrota = models.CharField(max_length=50, choices=MAO_DERROTA, default=None)
Oh right, if it is a mandatory field it does not let save being in this first correct option?
– Gabriel Alves
test, gave right, up to the obligation of choice, thank you very much Sidon
– Gabriel Alves
Yes, but the ideal is to treat this and warn the user.
– Sidon
put it like this: MAO_DERROTA = ( (', 'Choose your hand'),
– Gabriel Alves
Good! Django is badass! :-)
– Sidon