Why do you want to change the User model?
This might be a useful read for you if you want to store more info about a
user...
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/7 hc w <skysoari...@yahoo.com.cn>

> Hiiiiii, all
>
> I just want to add a foreign key--'FourS'-- to the user model .I have
> modified it as following.it works on our dev env in windows but failed in
> product env in linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can
> anyone tell me why and some solution?  Thanks
>
> MODEL:
>
> from django.db import models
> from django.contrib.auth.models import User
> from cyt.glorail.models import FourS
>
> from django.contrib.admin import validation
>
> # Create your models here.
> #class UserProfile(models.Model):
> #    user = models.ForeignKey(User,unique=True)
> #    dealer = models.ForeignKey(FourS)
> #    class Meta:
> #        db_table = u'auth_userprofile'
>
> from django.contrib.auth.admin import UserAdmin
> import datetime
> class ProfileBase(type):
>     def __new__(cls, name, bases, attrs):
>         module = attrs.pop('__module__')
>         parents = [b for b in bases if isinstance(b, ProfileBase)]
>         if parents:
>             fields = []
>             for obj_name, obj in attrs.items():
>                 if isinstance(obj, models.Field): fields.append(obj_name)
>
>                 User.add_to_class(obj_name, obj)
>             UserAdmin.fieldsets = list(UserAdmin.fieldsets)
>             UserAdmin.fieldsets.append((name, {'fields': fields}))
>         return super(ProfileBase, cls).__new__(cls, name, bases, attrs)
>
> class Profile(object):
>     __metaclass__ = ProfileBase
>
> class MyProfile(Profile):
>     dealer = models.ForeignKey(FourS)
>     #dealer = models.IntegerField(null=True,
> blank=True,db_column='dealer_id')
>
> ERROR MESSAGE:
>
> ImproperlyConfigured at /admin/auth/user/1/
> 'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is
> missing from the form.Request Method: GET
> Request URL: http://192.168.0.116/admin/auth/user/1/
> Exception Type: ImproperlyConfigured
> Exception Value: 'UserAdmin.fieldsets[5][1]['fields']' refers to field
> 'dealer' that is missing from the form.
> Exception Location:
> /usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in
> check_formfield, line 254
> Python Executable: /usr/local/bin/python
> Python Version: 2.5.4
> Python Path: ['/pyweb', '/usr/local/lib/python2.5/site-packages/django',
> '/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg',
> '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
> '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5',
> '/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk',
> '/usr/local/lib/python2.5/lib-dynload',
> '/usr/local/lib/python2.5/site-packages']
>
>
> ------------------------------
> 好玩贺卡等你发,邮箱贺卡全新上线! >
> <http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to