#6032: Make User and Group extendable
-----------------------------------------------------+----------------------
Reporter: Benjamin Wiegand <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component: Database
wrapper
Version: SVN | Keywords: database,
user, group, extension
Stage: Unreviewed | Has_patch: 0
-----------------------------------------------------+----------------------
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.).
--
Ticket URL: <http://code.djangoproject.com/ticket/6032>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---