模型.py
class Product(db.Model):
product_name_jp = db.StringProperty(required=True)
product_code = db.StringProperty(required=True)
class ProductPrice(db.Model):
product = db.ReferenceProperty(Product,
collection_name='price_collection')
quantity = db.IntegerProperty()
price = db.IntegerProperty()
表格.py
class ProductPriceForm(forms.Form):
f_product = forms.ModelField(model=Product, default=None, label="Product Name")
f_quantity = forms.TextField("Quantity ", required=True)
f_price = forms.TextField("Price ", required=True)
视图.py
def addproductprice(request):
productprice_form = ProductPriceForm()
if request.method =="POST" and productprice_form.validate(request.form):
productprice_form.save()
return render_to_response('myapp/message.html',{'form':productprice_form.as_widget(), 'message':'Insert Produce Price xxx '})
结果是
https://dl.dropboxusercontent.com/u/27576887/StackOverFlow/2.JPG
https://dl.dropboxusercontent.com/u/27576887/StackOverFlow/3.jpg
我的问题:如何显示 product_name_jp 而不是“myapp.models.Product object at xxx”
谢谢