Skip to content

ZibMedia/django-longer-userfields

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-longer-userfields provides a migration and a monkeypatch for the django auth.user model to allow customisable field lengths for usernames and email addresses.

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-userfields and dependancies.

  • pip install git+git://github.com/URpages/django-longer-userfields.git

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

  • pip install South==0.7.5

You will also need to install django-appconf to use the neat configuration overrides.

  • pip install django-appconf==0.4.1

Step 2. Add longeruserfields to your installed apps.

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

settings.py

INSTALLED_APPS = ("longeruserfields",) + 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 36.

settings.py

LONGERUSERFIELDS_USERNAMELENGTH = 75  # optional, default is 36.

Step 4. (Optional) Specify a custom email length

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

settings.py

LONGERUSERFIELDS_EMAILLENGTH = 100  # optional, default is 255.

Step 4. Run the migration

$ python manage.py migrate longeruserfields

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 for usernames and the 75 character limite for email addresses.

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

urls.py

from longeruserfields.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

This has been forked and improved upon based on madssj implementation.

Todo

Implement a way to allow usage of custom model for users

About

An app to easily provide a longer username field for django.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%