BadValueError: Property title is required

M

michal.bulla

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
 
C

Chris Rebert

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)
The problem is that I'm getting an error BadValueError: Property title
is required. Can you help me with that ? Thanks

Try asking on the Django mailing list:
http://groups.google.com/group/django-users

Cheers,
Chris
 
C

Casey Dwyer

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top