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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment