Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Deje DECIMALFIELD en blanco si no se cumplen los criterios

Estoy intentando dejar un DECIMALFIELD en blanco. Me gustaría que mi "declaración if" deje el campo en blanco si no cumple con los criterios. Mi modelo ya está configurado en blank=True, null=True .

 def clean_xrate(self): xrate_date = self.cleaned_data.get(str("date")) currency = self.cleaned_data.get("currency") curr = currency if not xrate_date: raise ValidationError('Error') elif curr == 'USD': xrate = 'NULL' <---This doesn't work. ☹️ else: prior_date_rate = cr.get_rate(curr, 'USD', xrate_date) xrate = "{0:.4f}".format(prior_date_rate) return xrate

¡Gracias de antemano por tu ayuda!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

None en python hará NULL en la base de datos (la mayoría de los dbs). Entonces puedes hacer

 xrate = None
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!