Suppose there are 7 choices ,e.g 7 days
I want all the name of 7 days in a list
I do not want to chhose a single one
I think you can use model choice field name like this,
Let say you have model like below,
class Test(models.Model):
APPROVED_CHOICE = [('Y', 'Approved'), ('N', 'Pending'), ]
approved = models.CharField(
max_length=1, choices=APPROVED_CHOICE, default='Y')
slug = models.SlugField(max_length=2000, null=True, blank=True)
Now you can retrieve all the corresponding APPROVE_CHOICE field like below,
#Model.field name
print(Test.APPROVED_CHOICE)
@Aruntck i want result like ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] all these days are in choice field
- ashutoshmishra333 4 years, 7 months agot=Test() new=t.APPROVED_CHOICE for i in new: print(i[1]) task completed
- ashutoshmishra333 4 years, 7 months agoCan you close the ticket using techions answer?. Otherwise as per policy we will choose and close the ticket.
- Vengat
Is this what you are expecting ??