tags:

views:

48

answers:

2

I inherited form the django user model like so:

from django.db import models
from django.contrib.auth.models import User, UserManager
from django.utils.translation import ugettext_lazy as _

class NewUserModel(User):
    custom_field_1 = models.CharField(_('custom field 1'), max_length=250, null=True, blank=True)
    custom_field_2 = models.CharField(_('custom field 2'), max_length=250, null=True, blank=True)

    objects = UserManager()

When i go to the admin and add an entry into this model, it saves fine, but below the "Password" field where it has this text "Use '[algo]$[salt]$[hexdigest]' or use the change password form.", if i click on the "change password form' link, it produces this error

Truncated incorrect DOUBLE value: '7/password'

What can i do to fix this?

+1  A: 

The best way to extend Django's User model is to create a new Profile model and identify it through the AUTH_PROFILE_MODULE setting. See http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/, and http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

This adds a get_profile() method to User instances which retrieves your associated model for a given User.

Chris Lawlor
but i don't want to replace the current user profile, because i need to extend the user model to serve several different profile types
Jerome
That requirement changes the scope of your question significantly - I think it would be best to open a new one detailing your multiple profile requirements.
Chris Lawlor
A: 

While doable (I did it once and regret it) using inheritance to extend the User model is not the best idea. I'd suggest you take Chris' advice and extend the User model with 1-1 relationship as it is the "standard" and "supported" way of doing it, and the way reusable apps deal with user profiles. Otherwise you need to implement an authentication backend if you want to do it by inheritance. So if you MUST do it see this. But be warned, you'll stumble across other problems later.

Vasil