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

132
Views
Cómo establecer el valor de un campo de modelo realizando una ecuación entre otros campos de modelo

Quiero establecer el valor de un campo modelo realizando una ecuación entre otros campos modelo. Aquí está mi modelo:

 class Current(models.Model): time = models.IntegerField(default=0) post_score = models.ForeignKey(PostScore, blank=True, null=True) comment_score = models.ForeignKey(CommentScore, blank=True, null=True)

Digamos que quiero crear un nuevo campo llamado rate , que se calcula mediante:

 (post_score + comment_score) / time

es posible?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Algo como esto:

modelos.py

 class Current(models.Model): .... def get_current_rate(self): return (self.post_score + self.comment_score) / self.time

En vistas.py :

 from mymodels import Current def someview(): .... rate = Current.get_current_rate()
about 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!