Package: django-funky-user
# Django Funky User**Django 1.5 user model enhancements***This is a work in progress, some functionality is not finalized.*Django Funky User is a Django application with various functionalityto replace the built-in Django User model. It is compatible with Django 1.5 andabove.The intention of the project is to be able to easily use (long) email addressesas usernames, have the reset password view send HTML email and fix other minorannoyances with Django's otherwise brilliant auth built-in package.It also includes a sensible user registration/activation process and is verywell suited to bootstrap new projects with basic registered user functionality.Before digging in too deep, you should be familiar with custom user models in Django:https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#substituting-a-custom-user-model## Features* An extendable User model that utilizes email as username, and allows long email addresses* URL configuration (and optionally templates) for Django's built-in auth views* User registration and email verification functionality* Password reset email with HTML alternativeYou are free to extend the provided User model with your own fields, and youcan freely choose what included functionality you want to use in your project.### Built-in Django views configurationIf you use the provided URL configuration, it sets up the following built-in Djangoviews with sensible default templates.* Login and logout* Password change* Password reset### User registrationUser registration functionality and templates is also included and works asfollows:* User signs up for an account* User receives an activation email* User clicks activation link in mail, account is activated/email is verifiedand user is automatically logged in## InstallationInstall `django-funky-user` (available on PyPi):pip install django-funky-userAdd it to `INSTALLED_APPS` in your `settings.py` (so Django can locatetemplates):INSTALLED_APPS += ['funky_user']### Vanilla setupIf you don't need any additional fields on the user model, and want to use allincluded functionality, set your project up like this:Add to your root URL configuration (`urls.py`):urlpatterns = patterns('',...url(r'^account/', include('funky_user.urls')),)Define the bare bones user model in your settings:AUTH_USER_MODEL = 'funky_user.User'Remember to run the `syncdb` management command to create the database table.## Usage and customizationsSee example usage of customizations in the example/demo_project/accountsdirectory.### Model referencesWhen refering to the user model in your code, you should avoid referencingthe actual model and instead do something like this (from the[Django docs](https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#referencing-the-user-model)):from django.contrib.auth import get_user_modelUser = get_user_model()user = User.objects.get(id=1)When you create a relation to your user model, you should utilize the setting:from django.conf import settingsfrom django.db import modelsclass BlogPost(models.Model):author = models.ForeignKey(settings.AUTH_USER_MODEL)### Custom User modelYou can easily extend the provided model with your own fields and methods.Create a new application (eg. `accounts`) and create a new model:from funky_user.models import AbstractBaseUserclass User(AbstractBaseUser):website = models.URLField(_('website'))twitter_handle = models.CharField(_('twitter handle'), max_length=100)When you create your own model, you must point the `AUTH_USER_MODEL` settingto it.AUTH_USER_MODEL = 'accounts.User'#### PermissionsIf you want permissions support (per user, for groups, etc, provided bydefault in earlier versions of Django), you can use the `PermissionsMixin`provided by Django:from django.contrib.auth.models import PermissionsMixinfrom funky_user.models import AbstractBaseUserclass User(AbstractBaseUser, PermissionsMixin):website = models.URLField(_('website'))#### User model in Django adminFor the custom User model to work with the Django admin, we had to override itsince it depends on a `username` field. We have provided a basic adminconfiguration that works with the default model.If you don't want the provided admin configuration, unregister it and add yourown: In your application's `admin.py` file:from django.contrib import adminfrom django.contrib.auth import get_user_modeladmin.site.unregister(get_user_model())You can subclass the provided admin configuration and override the things youneed.### Included views and URL configurationThe URL configuration is split into two modules: login, logout, password changeand password reset (Django's built-in views) are located in `funky_user.urls.auth`,and the registration functionality is in `funky_user.urls.signup`. If you wantto utilize both, you can import from `funky_user.urls` directly.If you want custom functionality in the same URL namespace, you can just extendthe provided configuration in your own URL configuration:from django.conf.urls import patterns, urlfrom funky_user.urls import urlpatternsurlpatterns += patterns('accounts.views',url(r'^edit/$', 'edit', name='user-edit'),)### TemplatesSince every project has different requirements for templates, we have chosennot to include them with the `funky_user` package. Instead they are availableseparately, in the `tests/templates/auth` folder. Just drop them in yourproject's template folder and you should have a decent starting point.(They fit perfectly with Twitter's Bootstrap project.)## Implementation notes* We would like to know which of our registered users has logged in and havethe `last_login` field be nullable. But to override it, we need to duplicateDjango's `AbstractBaseUser` model with password functionality, etc. Instead, weset `last_login` to a date way back (1970-01-01) when a user registers.### TODO_Developer notes_Things to do:* Only send activation mail if user is inactive?* Email field in login as EmailField?* Remove dependency on django-groove, include send_html_email function?* Provide example User models in documentation, remove from models.py?* More testsRandom thoughts:* Don't include a concrete class, so we don't have to manage migrations in this project?* Add translations* Support for changing email addresses?* Package name: django-funky-user* Module name: funky_user* Template directory name: auth?* URL name prefix: user? account? accounts?