Hi, I want to update the value of Status if num_serie isn’t null
num_serie = models.CharField(max_length=10, verbose_name='número de série',blank=True)
status = models.CharField(choices=STATUS, max_length=10, default='Orçamento', verbose_name='status')
On clean works (see the console)
def clean(self):
print(f'status:{self.status}, ')
if self.num_serie:
self.status = 'Liberado'
self.valida = 1
if self.valida == 1:
self.libera_producao = 1
print(f'status:{self.status}, ')
server-1 | [06/Mar/2024 12:56:42] "GET /admin/jsi18n/ HTTP/1.1" 200 8876
server-1 | status:Orçamento,
server-1 | status:Liberado,
server-1 | [06/Mar/2024 12:56:48] "POST /admin/rotinas/fichadados/add/ HTTP/1.1" 200 39473
server-1 | [06/Mar/2024 12:56:49] "GET /admin/jsi18n/ HTTP/1.1" 200 8876
but when the page refreshes, the value dosn’t update
Is there a way to make this change happens live, while I type “Número de série:”?
The value of ‘status’ should change depending if “Número de série:” is blank or not.
If blank 'Orçamento", else ‘Liberado’
It’s correct to use clean metod for this?