Skip to main content

Alternates user models for use with django >= 1.5

Project description


Put altuser in INSTALLED_APPS


and configure your preferred user model from available altuser/,
for example

AUTH_USER_MODEL = 'altuser.MailSocialUser'



If you use this User model with another Profile model you
should put this field on you Profile model

user = models.OneToOneField(settings.AUTH_USER_MODEL,

If you have multiple profile types, you should use User.get_profile() to get
the right profile associated with this user, but you also must set


to a list of backward relation names (relate_name), of various profiles you have.
For example if you have two models, client and managers, associated with a OneToOneField to
our user model, and they have different related_name, one client_profile and the other
manager_profile, then ALTUSER_PROFILES_BREL must be ['client_profile', 'manager_profile']


Actually you can also use the internal profile_type generic relation
on the provided AbstractMailUser, that will permit you to coerce one
profile type per user, it is up to you if using that or not.

# used in this way: self.user.get().usermodelfield
user = generic.GenericRelation(settings.AUTH_USER_MODEL,

Generic relations in this way permits to have your user and profile
in the same inline and for example in the admin:

from django.contrib import admin
from .models import MannequineProfile
from django.contrib.auth import get_user_model
from django.contrib.contenttypes import generic

class UserInline(generic.GenericTabularInline):
ct_field = 'profile_type'
ct_fk_field = 'profile_id'
exclude = ('last_login', 'is_staff', 'is_superuser',
'groups', 'user_permissions' ,'likes',

class ProfileAdmin(admin.ModelAdmin):
inlines = [
], ProfileAdmin)

Note also, that if you delete an object that has a GenericRelation, any objects which have a GenericForeignKey pointing at it will be deleted as well.
In the example above, this means that if a Profile object were deleted, any user objects pointing at it would be deleted at the same time.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-altuser-0.4.tar.gz (18.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page