Z
Z
zigen2016-01-20 22:33:43
Django
zigen, 2016-01-20 22:33:43

How to implement a post timer in Django?

Good afternoon.
Maybe someone has done something similar in their practice.
I want to add a DateTime field to the model, in which to specify the date and time when the record in the model will be published.
Those. for example, he added several entries in the admin panel, indicated this field, and these entries will be displayed on the site after a given time.
One option I see is to customize the model manager and compare the current datetime with the specified one.
But something tells me that this is a crooked solution.
Please advise the right way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-01-21
@zigen

One option I see is to customize the model manager and compare the current datetime with the specified one.
normal solution.
Do not forget to leave the standard manager, so as not to rake problems in the admin panel later
class MyModel(Model):
    # .....
    objects = Manager()
    ready_for_pub = CustomManager()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question