在gae中,其他表中增加一个记录,然后在本表中引用的时候,不会马上显示出来,除非重启服务器或者重新编译。所以,研究1,2天,有如下收获:
欢迎指正。
def getAllColor():
query = GqlQuery("select * from ModBaseColor");
arr = []
for q in query:
arr.append((q.key(),q.name))
return arr
def getAllSize():
query = GqlQuery("select * from ModBaseSize")
arr = []
for q in query:
arr.insert(0 , (q.key() , q.name))
return arr
class ProductForm(forms.Form ):
def __init__(self , *args , **kwargs):
super(ProductForm , self).__init__(*args , **kwargs)
self.fields['color']._set_choices(getAllColor())
self.fields['size']._set_choices(getAllSize())
name = forms.CharField()
size = forms.ChoiceField()
color = forms.ChoiceField()
欢迎指正。