Answer the question
In order to leave comments, you need to log in
How to change field value automatically after some time in django?
Couldn't formulate the question correctly. The point is the following. I am making a bulletin board website. There is a model:
class Hotel(models.Model):
vip = models.BooleanField(default = False, verbose_name = 'VIP размещение')
pay = models.DateField(verbose_name="День оплаты",default=datetime.now)
on_off = models.BooleanField(default=False, blank=True, verbose_name="Включить обьявление")
title = models.CharField(max_length=200, verbose_name="Название")
slug = models.SlugField(unique=True, verbose_name="URL")
category = models.ForeignKey(Category, verbose_name='Тип обьявления')
image = models.ManyToManyField(MyImage,default = '', verbose_name="Фото")
place = models.ForeignKey(Place, verbose_name='Место расположения')
content = HTMLField(verbose_name='Информация')
Answer the question
In order to leave comments, you need to log in
Disable: judging by the fact that the pay date field is just a date, then you just need a cron task that will run once a day for all ads and disable ads that have expired.
Enable: To enable immediately upon receipt of payment, use the post_save signal. If enabled the next day, include the logic in the same deactivation cron task. you just need to add a start date to the model
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question