您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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'))