Answer the question
In order to leave comments, you need to log in
How to edit the value through the admin panel?
Good time of the day!
Tell me how to change the value through the admin panel
For example, there is a request to display publications for a certain period
There is a filtering by the number of likes
qs = self.get_published()
qs = qs.filter(total_votes__gt=15)
Answer the question
In order to leave comments, you need to log in
You can make constants:
-> There is a Constant model: title - the name of the constant (unique, text) , value - the value of the constant (null, text)
-> In the code:
constant, created = Constant.objects.get_or_create(title="MIN_LIKES_COUNT")
if created: constant.value = "15" # По дефолту, чтобы не было ошибок
qs = qs.filter(total_votes__gt=int(constant.value))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question