Search code examples
google-app-enginedjango-modelsgoogle-datatable

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):
    categorylist=db.StringListProperty()

Please help.

Thank You


Solution

  • 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