我想扩展satchmo商店中包含的基本用户注册表单和配置文件,但我遇到了问题。延伸satchmo用户配置文件
这是我做了什么:
创建一个新的应用程序“extendedprofile”
写道,扩展了satchmo_store.contact.models类,并添加自定义名称字段models.py。
写了一个admin.py,取消注册Contact类并注册我的newapp,但这仍然显示我默认的用户配置文件表单。
也许有人可以告诉我正确的方法来做到这一点?
我想扩展satchmo商店中包含的基本用户注册表单和配置文件,但我遇到了问题。延伸satchmo用户配置文件
这是我做了什么:
创建一个新的应用程序“extendedprofile”
写道,扩展了satchmo_store.contact.models类,并添加自定义名称字段models.py。
写了一个admin.py,取消注册Contact类并注册我的newapp,但这仍然显示我默认的用户配置文件表单。
也许有人可以告诉我正确的方法来做到这一点?
这听起来像是你做得对,但它会帮助你,如果你张贴你的来源。当我走这条路线时,我将扩展配置文件视为与用户型号内嵌:
class UserProfileInline(admin.StackedInline):
model = UserProfile
fk_name = 'user'
max_num = 1
fieldsets = [
('User Information', {'fields': ['street', 'street2', 'city', 'state', 'country', 'latitude', 'longitude']}),
('Site Information', {'fields': ['sites']}),
('User Account', {'fields': ['account_balance']}),
]
class NewUserAdmin(admin.ModelAdmin):
inlines = [UserProfileInline, ]
admin.site.unregister(User)
admin.site.register(User, NewUserAdmin)
希望可以帮到你。
写道,扩展了 satchmo_store.contact.models类和 添加自定义名称字段models.py。
写道,注销 Contact类和注册我的NEWAPP 但仍显示我的默认 用户配置文件形式的admin.py。
这与覆盖django注册用户类有关; satchmo项目为User类创建一个外键(从0.9.2开始)。但是你想要做的是创建一个扩展的配置文件类与新的领域。
因此,在这种特殊情况下,你会需要做一些事情来覆盖配置文件模板,显示联系方式:
satchmo_store.contact.views
,但使用的而不是联系人类你自己的类)satchmo_store.contact.forms.ExtendedContactInfoForm
表单类。contact/view_profile.html
模板以包含自定义名称字段。然后,您可能需要取消注册Contact类,如上所示,admin.site.unregister(Contact)
,并且仅管理您的新子类。