0
from django.db import models
from django.contrib.auth.models import User
class MySiteProfile(models.Model):
# This is the only required field
user = models.ForeignKey(User, unique=True)
# The rest is completely up to you...
favorite_band = models.CharField(max_length=100, blank=True)
favorite_cheese = models.CharField(max_length=100, blank=True)
lucky_number = models.IntegerField()
問題是, User._meta.admin
和MySiteProfile._meta.admin
都返回NoneType。我刪除並重新創建了整個數據庫,但管理面板中沒有出現新的字段; AUTH_PROFILE_MODULE已設置。如何在Django 1.3用戶配置文件中實現管理元字段?
有很多障礙;我不必註冊自己的MySiteProfileAdmin,而是使用InlineAdmin for MySiteProfile重新註冊UserAdmin; http://stackoverflow.com/questions/6183132/django-inlinemodeladmin-extra-option-not-working - > http://stackoverflow.com/questions/3400641/how-do-i-inline-edit-a-django -user-profile-in-the-admin-interface - >目前,它工作正常.. –