Hello.
When using customized auth models, i found that the right way of
doing
that is:
class UserProfile(models.Model):
url = models.URLField()
home_address = models.TextField()
phone_numer = models.PhoneNumberField()
user = models.ForeignKey(User, unique=True) # <-----
(from
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/,
and a few other sites)
But in admin interface, that doesnt look good. We would need to first
add a User in auth, than add our user
with its specific fields...
So, subclassing seemed to be a good answer, even subclassing not being
a good answer for many things,
so i did something just like this:
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin
from django.contrib import admin
# Create your models here.
class RsUser(User):
phoneNumber = models.CharField(max_length=10)
class RsUserAdmin(UserAdmin):
pass
admin.site.unregister(Group)
admin.site.unregister(User)
admin.site.register(RsUser,RsUserAdmin)
Simple like that.
At first, all seems fine, the user creation form works, but when i
finish adding a user the right
thing would be going to the User Update screen for that user, but that
doesnt happen, becouse
what i have inserted was a User, not a RsUser! Actualy, i could edit
that user if i dont unregister
User admin interface.
Well, after writing so much bad code, my goal would only to have the
complete admin screen
for users without having to write entirely new admin model config for
my new models, using as
much as already writen django admin code :D
Is that possible?
Well, thank you anyway!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---