2016-10-25 195 views
1

我想在Django中扩展model.User(使用SQLite3)。这里是我的用户配置文件模型:Django扩展模型。用户

class UserProfile(models.Model): 
    user = models.ForeignKey(User, unique = True, related_name = 'user') 
    bio = models.TextField(blank = True, null = True) 
    birth_date = models.DateField(blank = True, null = True) 
    followers = models.ManyToManyField('self', symmetrical=False, null = True, blank = True) 

但是,当我运行服务器时,我没有看到UserProfiles作为单独的选项卡。有一个用户标签,但我没有看到我的任何自定义字段。我做错了什么或者这是Django的预期行为?我怎么能测试这么多的代码(手动很好,但怎么做?),只是为了看看行为是否如预期。

非常感谢!

+1

的标签?你的意思是管理员标签? – levi

+0

我的意思是超链接!默认情况下,超链接指向User和Group,但UserProfiles看不到一个! –

+1

超链接究竟在哪里? – levi

回答

1

Okey,您需要将UserProfile模型添加到您的管理面板。

其中UserProfile位于内部app文件夹,你会发现一个名为admin.py

添加文件如下:

from .models import UserProfile 

admin.site.register(UserProfile)