开发者

Google App Engine model for Select Box

I have category model, in which I want to load some default data. How can I achieve it? This is model is for a select box, which is extensible for different applications later

This is the model I have designed it, I tried verifying choice

class Category(db.Model):
    category开发者_开发技巧list=db.StringListProperty()

Please help.

Thank You


Select Box Model



Class Category (db.Model):
       name = db.StringProperty()

Right now, I use this in this fashion (I'm using Django Framework).

In the views.py I make an array


options =["Car", "Motor Bikes", "Bikes", "Apparel"]   

and in the templates I populate it this way


{% for option in options %}
   {% ifequal edit_nw.category option %}
         {{option}}
    {% else %}
         {{option}}     
    {% endifequal %}
{% endfor %}

All I want is to use this options to be a result of model like Category.all(), should have some default data loaded for the entire app. If necessary, Ill add categories from admin panel


Check out the docs. There is default attribute for property.

default
A default value for the property. If the property value is never given a value, or is given a value of None, then the value is considered to be the default value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜