我正在开发一个订阅网站,其中包括一个“注册”应用程序。我还使用django oscar商店进行一次性购买,并在整个站点中使用它的UserAddress类。但是,由于我的地址和用户名/电子邮件表单在订阅注册时在同一页面上,所以我使用了一个临时的定制模型表单,它基于AbstractAddress,在注册中有特定的字段/表单.py公司名称:
# signup/forms.py
from oscar.apps.address.abstract_models import AbstractAddress
class CustomAddressForm(ModelForm):
class Meta:
"""
Using AbstractAddress because UserAddress requires a User and there
is none when signup form is displayed. A UserAddress instance is then
created later, using the User object created after request.POST.
"""
model = AbstractAddress
fields = ['line1', 'line2', 'line4', 'state', 'postcode', 'country']
安装了应用程序后:
^{pr2}$在Django 1.8中运行良好,但我刚刚尝试在部署之前升级到1.9,得到以下错误消息:
File "path/to/python3.4/django/db/models/fields/related.py", line 942, in formfield(self.name, self.remote_field.model))
Cannot create form field for 'country' yet, because its related model 'address.Country' has not been loaded yet
大概我可以将我的自定义模型表单移到django-oscar核心中,但我不愿意。在
我见过this问题,但由于我的例子中的模型在表单的元字段列表中被称为字符串“country”,我不确定如何在这里导入Country
模型。在
我在django1.9中找不到任何ModelForms发生变化的迹象。为什么我的表8.1中有人不知道?在
目前没有回答
相关问题 更多 >
编程相关推荐