﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6032	Make User and Group extendable	Benjamin Wiegand <beewee@…>	nobody	"Hi,

I'm developing a django application where I've additional data to store for users (e.g. a signature, settings, etc.). I solved this by creating a new model called UserProfile, which stores this data and has a ForeignKey user to the django User object. This sollution works fine for some small things but sometimes it's really copious, e.g. if I want to get the user data of all users that belong to a special group. In this case I had to do something like this:
{{{
group = Group.objects.get(id=123)
users = group.user_set.all()
profiles = UserProfile.objects.filter(user__id__in=[u.id for u in users])
}}}
Now I'm wondering whether extending the User and Group model like this would be possible:
{{{
# in models.py
from django.contrib.auth.models import User, Group

class MyUser(User):
    signature = forms.CharField()
    post_count = forms.IntegerField()


class MyGroup(Group):
    def get_absolute_url():
        return 'my_own_url'
}}}
{{{
# in settings.py
DJANGO_USER_MODEL = 'models.MyUser'
DJANGO_GROUP_MODEL = 'models.MyGroup'
}}}

signature and post_count then would be stored in the same database table as the normal user data (username, date_joined, etc.)."		closed	Database layer (models, ORM)	dev		duplicate	database, user, group, extension	webteam@…	Unreviewed	0	0	0	0	0	0
