On May 31, 1:21 am, "michal.bulla" <michal.bu...@gmail.com> wrote: > 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
Required properties must be declared in the constructor. Try this instead: category = Category(title=self.request.get('title')) category.put() -- http://mail.python.org/mailman/listinfo/python-list