Answer the question
In order to leave comments, you need to log in
Timer on django form?
The user is authorized, and in front of him is a form, filled out and sent. How can I disable the form for 24 hours after that? You can't forget to send the o5 form for 24 hours, in general, for one user, where to google?
Answer the question
In order to leave comments, you need to log in
store the date of the last submission of the form by the user and do not display it (well, or submit) if 24 hours have not passed yet.
https://docs.djangoproject.com/en/1.8/ref/models/f...
class Foo(models.Model):
user = models.ForeignKey(MyUser)
action_datetime = models.DateTimeField(auto_now_add=True)
from datetime import datetime, timedelta
def form_view(request):
if Foo.objects.get(
user=request.user,
action_datetime__gt=datetime.now() - timedelta(days=1)):
# do what u want
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question