Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django一行代码解法 #29

Open
LeiShi1313 opened this issue Oct 22, 2019 · 2 comments
Open

Django一行代码解法 #29

LeiShi1313 opened this issue Oct 22, 2019 · 2 comments
Labels

Comments

@LeiShi1313
Copy link

这行

user = authenticate(request, username=username, password=password)

改成

user = User.objects.get(username='admin')

即可以任意用户名密码登录成admin

@LeiShi1313
Copy link
Author

对不起,我标题党了,得再加行import:

from django.contrib.auth.models import User

@sgalal
Copy link
Contributor

sgalal commented Oct 24, 2019

import 也是对象,所以还是可以写成一行(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants