[英]Django 1.4 - extend user model and admin interface
Let's have 2 models that extends the user model called Ext1
and Ext2
declared as follow: 让我们有2个模型来扩展声明为
Ext1
和Ext2
的用户模型,如下所示:
class ExtN(models.Model):
user = models.OneToOneField(User)
extra_param = models.xxxField()
then I declare in application specific admin.py
file something like: 然后在应用程序特定的
admin.py
文件中声明如下内容:
class ExtNInline(admin.StackedInline):
model = ExtN
can_delete = False
in which file do I need to put the following code, in order to see the form to edit both models related to the user? 为了查看用于编辑与用户相关的两个模型的表单,我需要在以下文件中放入以下代码?
class UserAdmin(UserAdmin):
inlines = (Ext1Inline, Ext2Inline, )
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
Thanks in advance. 提前致谢。
You should put it in the same admin.py
file 您应该将其放在相同的
admin.py
文件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.