[英]Django user groups login check
I created a group as a users for my django project.我为我的 Django 项目创建了一个用户组。 I want to create users with no admin permission.我想创建没有管理员权限的用户。 I just want them to be able to log-in website.我只希望他们能够登录网站。 I have a form, I want that only users can fill this form.我有一个表格,我希望只有用户才能填写此表格。 So I want to check if they are logged in or not.所以我想检查他们是否登录。 Is it possible?是否可以?
is_superuser
and is_staff
in User
model are meant for this kind of stuff. User
模型中的is_superuser
和is_staff
用于此类内容。 Create your users with User.objects.create_user()
method and they will be created with limited access and no admin privilege.使用User.objects.create_user()
方法创建您的用户,他们将以有限的访问权限和没有管理员权限创建。
Also for checking privileges on pages, use decorators like login_required
or mixin and permissions classes to control access to pages.同样为了检查页面上的权限,使用装饰器(如login_required
或 mixin 和权限类)来控制对页面的访问。
And for advance Authorization checking there are packages like django-guardian
which are awesome but need more understanding of django.对于预先授权检查,有像django-guardian
这样的软件包,它们很棒但需要更多地了解 django。
By the way, your question is not good and I suggest add more details and a specific problem that we can help much better.顺便说一句,你的问题不好,我建议添加更多细节和一个特定的问题,我们可以更好地提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.