太过我的网站了。
请参阅我的代码:
INSTALLED_APPS = (
...
'stronghold',
)
MIDDLEWARE_CLASSES = (
...
'stronghold.middleware.LoginRequiredMiddleware',
)
STRONGHOLD_PUBLIC_URLS = (
'/admin/',
)
...
from stronghold.decorators import public
...
@public
def index(request):
return render(request, 'index.html')
@public
def about(request):
return render(request, 'about.html')
class PersonList(ListView):
pass
class PersonDetail(DetailView):
pass
class PersonForm(CreateView):
pass
...
url(r'^admin/', include(admin.site.urls), name='admin'),
但是当我点击需要登录的链接时,如何重定向到登录页面?重定向到/ admin /
因为未登录时其余页面返回404.
答案 0 :(得分:0)
将LOGIN_URL = '/admin/'
添加到 settings.py 。