E
E
ekzotika2020-08-10 10:29:00
Python
ekzotika, 2020-08-10 10:29:00

How to check if an action was performed today?

Tell me, please, how can I check if a certain action was performed during the current day?

The code:

def get_messages_template(request) -> HttpResponse:
    if not request.user.is_authenticated:
        return HttpResponseForbidden()
    tmpl_text = ''
    tmpl_id = id_cleaner(request.POST.get('template_id', ''))
    try:
        obj = MessageTemplate.objects.get(pk=tmpl_id)
        tmpl_text = obj.text
    except Exception:
        traceback.print_exc()

    return JsonResponse({'success': True, 'template': tmpl_text})


I need to check if a message was sent today and if so, don't send it. If not, then send. The message is taken from the MessageTemplate table.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
javedimka, 2020-08-10
@ekzotika

Well, add one more field/table that will contain the date of the last message sent and check

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question