Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin how unlock your own account?

In Django admin I have by mistake locked myself by attempting the wrong password. I later of deleted the user and created another one using manage.py createsuperuser. However, it still says that I'm locked. How do I unlock myself?

It gives the following error when I try to log in using Django admin..

Account locked: too many login attempts. Contact an admin to unlock your account.

like image 496
Abhishek Jebaraj Avatar asked Feb 09 '17 11:02

Abhishek Jebaraj


People also ask

What is the default username and password for Django admin?

By default you have to use admin and the password is 123123.


2 Answers

Given your error message and 3 strike policy, I assume you have django-axes in your project. You may have it configured to block by IP, regardless of user. That would explain why creating a new user did not work.

Djang-axes documentation gives you an outline of how to clear lockouts.

manage.py axes_reset will reset all lockouts and access records.

If you are currently in production and do not want to risk resetting any valid lockouts, you could try resetting for just your ip

manage.py axes_reset ip will clear lockout/records for ip

So, for example on if you are logged in on the same computer your server is on, you can use localhost: manage.py axes_reset ip 127.0.0.1

If for some reason that doesn't work, you still have the option of manually deleting your AccessAttempt from your database. This assumes, of course, that you have access to your database, that your user has delete privileges, you are comfortable with sql, and you have not changed the default table name from django-axes.

delete from axes_accessattempt where username ='your_username'; where 'your_username' is the account you wish to unlock.

This can also by done by ip: delete from axes_accessattempt where ip_address='your_ip'; where 'your_ip' is the ip address from the computer you are using.

like image 87
Fred Avatar answered Sep 21 '22 09:09

Fred


Resetting attempts from command line:

  1. python manage.py axes_reset will reset all lockouts and access records.
  2. python manage.py axes_reset_ip [ip ...] will clear lockouts and records for the given IP addresses.
  3. python manage.py axes_reset_username [username ...] will clear lockouts and records for the given usernames.
  4. python manage.py axes_reset_logs (age) will reset (i.e. delete) AccessLog records that are older than the given age where the default is 30 days.
like image 45
Aliakbar Hosseinzadeh Avatar answered Sep 18 '22 09:09

Aliakbar Hosseinzadeh