{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://coderseye.com/#website","url":"https://coderseye.com/","name":"Coders Eye - Web Dev Tutorials and How-To Guides for Beginners","potentialAction":{"@type":"SearchAction","target":"https://coderseye.com/?s={search_term_string}","query-input":"required name=search_term_string"}},{"@type":"ImageObject","@id":"https://coderseye.com/2007/howto-reset-the-admin-password-in-django.html#primaryimage","url":"https://coderseye.com/wp-content/uploads/Howto-Reset-The-Admin-Password-in-Django.jpg","width":780,"height":500},{"@type":"WebPage","@id":"https://coderseye.com/2007/howto-reset-the-admin-password-in-django.html#webpage","url":"https://coderseye.com/2007/howto-reset-the-admin-password-in-django.html","inLanguage":"en-US","name":"Howto Reset The Admin Password in Django - CodersEye.com","isPartOf":{"@id":"https://coderseye.com/#website"},"primaryImageOfPage":{"@id":"https://coderseye.com/2007/howto-reset-the-admin-password-in-django.html#primaryimage"},"datePublished":"2016-06-12T18:44:07+00:00","dateModified":"2016-10-05T09:44:31+00:00","author":{"@id":"https://coderseye.com/#/schema/person/a56f7a71a0b69c1d5aad5ff1971f81ab"}},{"@type":["Person"],"@id":"https://coderseye.com/#/schema/person/a56f7a71a0b69c1d5aad5ff1971f81ab","name":"Stephanie Reigns","image":{"@type":"ImageObject","@id":"https://coderseye.com/#authorlogo","url":"https://secure.gravatar.com/avatar/9e9cb84680cc1ac746317f5391c51964?s=96&d=mm&r=g","caption":"Stephanie Reigns"},"description":"I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.","sameAs":[]}]}
HomefeaturedHowto Reset The Admin Password in Django

Howto Reset The Admin Password in Django

keep needing to do this, darn it! I leave a project for a few months, possibly push it live, and then I go back to fire up the dev server but I simply cannot remember the password I used for admin during development. Why don’t I use my stupid-development-password? I don’t know, but this seems to happen with some regularity. Luckily, it is trivial to fix with a few lines at the python commandline:

Deep:/opt/webapps/invisible bruce$ ./manage.py shell
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.contrib.auth.models import User

In [2]: users = User.objects.all()

In [3]: users
Out[3]: [<User: admin>]

In [4]: users[0].set_password('whatever');

In [5]: users[0].save()

That’s it, fire up the dev server again and your new password will get you in.

FOLLOW US ON:

I started out going to college for Business administration but soon found out that Coding would be a great way to have a sustainable career! I made coder's eye as my personal journey on learning how to code and sharing my Findings along the way. My vision with CE now is to be a way to help beginners that want to learn code but don't know where to start.

NO COMMENTS

Sorry, the comment form is closed at this time.