0

model.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

私の質問: "myapp.models.Product object at xxx" の代わりに product_name_jp を表示する方法

ありがとう

4

1 に答える 1