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

182
Views
How do I change the value of true or false to a text value type it I am checking the row in the entire table Note the table is of type datatables?

use django How do I change the value of true or false to a text value type it I am checking the row in the entire table

name item type items active
item1 15.0 True
item2 15.0 False

change values row active use jquery or django file view.py:

name item type items active
item1 15.0 displayed
item2 15.0 stope

help please

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The most elegant way is likely to specify choices for the BooleanField, so:

from django.db import models

ACTIVE_CHOICES = [
    (False, 'stope')
  , (True, 'displayed')
  ]

class MyModel(models.Model):
    # …
    active = models.BooleanField(choices=ACTIVE_CHOICES)

Then you can render the corresponding label in a template with:

{{ mymodelobject.get_active_display }}

It will also use these choices by default in a ModelForm, ModelAdmin, and serializers.

about 4 years ago · Juan Pablo Isaza Report

0

Without code, it is difficult to give a precise answer.

but the easiest way to set value based on a boolean in javascript is to use a ternary operator.

If true, active will be set to "displayed", if false, active will be set to "stope"

active = boolean_value ? "displayed" : "stope"

about 4 years ago · Juan Pablo Isaza 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!