The logic would be something along these lines (note that you'd need to sort out the "button click" side)
On Tuesday, 30 April 2019 12:57:33 UTC+2, Mayur Bagul wrote:
-- # class Car(models.Model):
# two_wheeler = models.CharField(validators=[validate_comma_separated_integer_list])
import random
car = Car.objects.get(pk=1)
numbers = car.two_wheeler.split(',')
random_item = random.sample(numbers, 1)
# repeat for the other similar field(s)
On Tuesday, 30 April 2019 12:57:33 UTC+2, Mayur Bagul wrote:
Hello community,i have created three fields in my model Data
- Two-wheeler
- four-wheeler
inside each field i have putted 5 values.now i wanted to display single random value from these two fields every time i click on button. and thats where im getting stuck.How to do this ?if any one have resources related to this issue please provide me and help me with your solution.Thanking you.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1fb39007-e94a-4893-880f-671d44a40162%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment