简体   繁体   English

Django allauth允许的网址

[英]Django allauth allowed urls

I just started with a Django project using allauth, I configured the basic settings, without using any 3rd party provider. 我刚开始使用allauth进行Django项目,配置了基本设置,而未使用任何第三方提供程序。 I've created a basic template for my profile page. 我已经为我的个人资料页面创建了一个基本模板。 Everything is working as expected so far, but if a go to localhost:8000/accounts/profile I can see the page even without log in before. 到目前为止,一切都按预期工作,但是如果转到localhost:8000 / accounts / profile,即使没有登录也可以看到该页面。 I've tried to look in the documentation how to define which page should require be logged in but I haven't found anything. 我试图在文档中查找如何定义应要求登录的页面,但未找到任何内容。

Any thoughts? 有什么想法吗? Thanks! 谢谢!

EDIT These are my allauth settings: 编辑这些是我的allauth设置:

#Allauth Config
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_SIGNUP_FORM_CLASS = 'picturesApp.forms.SignupForm'
ACCOUNT_EMAIL_VERIFICATION = 'none'

One possible way to do what you want is to decorate the view handling your profile page woth 'login_required' decorator. 一种执行所需操作的可能方法是装饰处理您的个人资料页面的视图,并使用“ login_required”装饰器。

Example: 例:

from django.contrib.auth.decorators import login_required
urlpatterns = patterns('',
   # MY PROFILE
   url(r'^$',
       login_required(MyProfileDetailView.as_view()),
       name="my_profile"
   )
)

This decorator verifies the user is logged in, otherwise it returns a redirect http response (to the login url). 该装饰器验证用户已登录,否则返回重定向http响应(至登录URL)。
Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM