Answer the question
In order to leave comments, you need to log in
How to change integer value through views?
hello. The question seems simple, but I was not able to solve this problem.
There is a model
class Profile(models.Model):
- - -
monetki = models.IntegerField(default=0)
Answer the question
In order to leave comments, you need to log in
What exactly is needed?
from app_name.models import Profile
profiles = Profile.objects.all()
# получить
for profile in profiles:
print(profile.monetki)
# присвоить
profiles = Profile.objects.filter(monetki=0)
for profile in profiles:
profile.monetki = 25
profile.save()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question