25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.py 521 B

5 년 전
5 년 전
12345678910111213141516
  1. from django.conf import settings
  2. from django.http import HttpResponseRedirect
  3. from django.core.urlresolvers import reverse
  4. class Public(object):
  5. def process_request(self, request):
  6. if settings.PUBLIC is False and not request.user.is_authenticated():
  7. acceptable_paths = [
  8. '/login/',
  9. '/private/',
  10. '/register/',
  11. ]
  12. if request.path not in acceptable_paths:
  13. return HttpResponseRedirect(reverse('users:private'))