2👍
If you work with test database, create set password for need user.
def login_as(self, browser, user):
# change password
password = 'q'
user.set_password(password)
user.save()
browser.get(self.live_server_url + '/admin/')
username_field = browser.find_element_by_css_selector('form input[name="username"]')
password_field = browser.find_element_by_css_selector('form input[name="password"]')
username_field.send_keys(user.username)
password_field.send_keys(password)
submit = browser.find_element_by_css_selector('form input[type="submit"]')
submit.click()
1👍
It seems to me that the answer to your questions is most likely No. The reason being that you never want to store a password in plain text without hashing it (and ideally also salting it). It IS POSSIBLE nevertheless to configure Django to not hash your password before storing it in your database. If you don’t hash it then you can do what you want:
admin = User.objects.get(username="admin")
password_field.send_keys(admin.password)
I would NOT recommend this. Also, it’s not possible to use the hashed version of the password in your login page to login either as the Django authentication backend will hash the already hashed input and it will NOT match.
Does this make sense?
- [Django]-Django Rest Framework – GenericViewSet with Authentication/Permission decorator
- [Django]-Celery: different settings for task_acks_late per worker / add custom option to celery
- [Django]-Getting a new user's Twitter email address with Django and django-allauth
- [Django]-How to implement Angular with Django
Source:stackexchange.com