Задать вопрос

Тел: +7 965 3737 888

482

Просмотров

4

Ответов

AdminPeepingMiddleware

Peeping middleware, that replaces active user to another one for current http request. Admin permissions required to activate, so you can place this snippet even on the production server. Very useful for debugging purposes. Wish it to be part of Django.

How to use:

Put this middleware after all other middlewares in the list. Then just add ?as_user=username or &as_user=username to the url, where username is the name of user whose views you want to see.

Вопрос полезен? Да0/Нет0
file_3040.py(1.1Кб)
None

Ответы (4):

Ответburiy:24.11.2007
Ответ полезен? Да0/Нет0

really due to django misbehaving with process_request errors it's not the matter to use raise or return.

Ответburiy:24.11.2007
Ответ полезен? Да0/Нет0

nobody mentioned wrong 'return Http404' instead of 'raise Http404'. fixed.

Ответburiy:18.10.2007
Ответ полезен? Да0/Нет0

yes, right, adding to the snippet

Ответphir:03.10.2007
Ответ полезен? Да0/Нет0

Had to add this to make it work. Otherwise, pretty nifty.

from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404