BadValueError: Property title is required

michal.bulla michal.bulla at gmail.com
Tue May 31 04:21:17 EDT 2011


Hello,

I'm trying to create simple method to create category. I set the model
category:

class Category(db.Model):
  title = db.StringProperty(required=True)
  clashes_count = db.IntegerProperty(default=0)

And the class New Category as well :

class NewCategoryPage(webapp.RequestHandler):
  def get(self):
    categories = Category.all().order('-title')

    template_values = { }
    path = os.path.join(os.path.dirname(__file__), 'templates',
'category_new.html')
    self.response.out.write(template.render(path, template_values))

  def post(self):
    category = Category()
    category.title = self.request.get('title')
    category.put()
    self.redirect('/')

Here is the template:

{%extends "base.html"%}
{%block body%}

<h2>Add New Category</h2>

<form action="" method="post">
  <div>Title: <input type="text" name="title" size="100" /></div>
  <div><input type="submit" value="Publish"></div>
</form>

{%endblock%}

The problem is that I'm getting an error BadValueError: Property title
is required. Can you help me with that ? Thanks



More information about the Python-list mailing list