Skip to content

Instantly share code, notes, and snippets.

@daddz
Created August 29, 2014 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daddz/1497d2c1d38402c2d2e6 to your computer and use it in GitHub Desktop.
Save daddz/1497d2c1d38402c2d2e6 to your computer and use it in GitHub Desktop.
Django custom AUTH_USER_MODEL password as plaintext
## customauth/admin.py
from django.contrib import admin
from customauth.models import MyUser
admin.site.register(MyUser)
## start the app
$ ./manage.py makemigrations
$ ./manage.py migrate
$ ./manage.py createsuperuser
$ ./manage.py runserver
## http://localhost:8000/admin/customauth/myuser
Add User -> Put something in "Password" and "Username" -> Save and continue editing
RESULT: password saved as plaintext
## customauth/models.py
from django.db import models
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
pass
## isthisabug/settings.py
"""
...
"""
INSTALLED_APPS = (
""" ... """
'customauth',
)
AUTH_USER_MODEL = 'customauth.MyUser'
## start with a new Django project
$ pip freeze -l
> Django==1.7c3
$ django-admin startproject isthisabug
$ cd isthisabug
$ ./manage.py startapp customauth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment