Coder Social home page Coder Social logo

django-longer-username's Introduction

django-longer-username provides a migration and a monkeypatch to make the django auth.user username field longer, instead of the arbitrarily short 30 characters.

It's designed to be a simple include-and-forget project that makes a little headache go away. Enjoy, and pull requests welcome!

Usage

Step 1. Install django-longer-username.

  • pip install longerusername

You will also need to install south to use the migration.

  • pip install south

Step 2. Add longerusername to your installed apps.

Add 'longerusername' to the top of your INSTALLED_APPS in settings.py

settings.py

INSTALLED_APPS = ("longerusername",) + INSTALLED_APPS

Step 3. (Optional) Specify a custom username length

If you want to specify a custom length, add it to settings.py. The default is 255 characters.

settings.py

MAX_USERNAME_LENGTH = 100  # optional, default is 255.

Step 4. Run the migration

$ python manage.py migrate longerusername

That's it, you should be good to go!

Notes about the built-in forms

This app also automatically monkey patches the User forms in the Django admin to remove the 30 character limit.

It provides a suitable replacement for the standard AuthenticationForm as well, but due to the implementation you must manually utilize it.

urls.py

from longerusername.forms import AuthenticationForm

urlpatterns = patterns('',
    # ...
    (r'^accounts/login/$', 'django.contrib.auth.views.login', {'authentication_form': AuthenticationForm}),
)

Credits

The monkeypatch for this is very largely based on celement's answer on stackoverflow

django-longer-username's People

Contributors

marltu avatar skoczen avatar waynelin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.