I
I
IIITRIX2021-06-23 10:52:32
Django
IIITRIX, 2021-06-23 10:52:32

Custom decorator in django?

Good day!
Help, how to write a decorator for this view?

def home(request):
  context = {
    'title': 'Главная'
  }
  if request.is_ajax():
    data = {
      "url": "/",
      "title": "Главная",
      "content": render_to_string("articles/list_ajax.html"),
    }
    return JsonResponse(data)
  return render(request, "articles/feed.html", context)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question