Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6718 > unrolled thread

BadValueError: Property title is required

Started by"michal.bulla" <michal.bulla@gmail.com>
First post2011-05-31 01:21 -0700
Last post2011-06-03 09:53 -0700
Articles 4 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  BadValueError: Property title is required "michal.bulla" <michal.bulla@gmail.com> - 2011-05-31 01:21 -0700
    Re: BadValueError: Property title is required Chris Rebert <clp2@rebertia.com> - 2011-05-31 01:32 -0700
      Re: BadValueError: Property title is required "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-05-31 07:28 -0700
    Re: BadValueError: Property title is required Casey Dwyer <caseydwyer@gmail.com> - 2011-06-03 09:53 -0700

#6718 — BadValueError: Property title is required

From"michal.bulla" <michal.bulla@gmail.com>
Date2011-05-31 01:21 -0700
SubjectBadValueError: Property title is required
Message-ID<8106c94d-04f5-4b36-a7dc-be3cff7fecff@b42g2000yqi.googlegroups.com>
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

[toc] | [next] | [standalone]


#6719

FromChris Rebert <clp2@rebertia.com>
Date2011-05-31 01:32 -0700
Message-ID<mailman.2311.1306830777.9059.python-list@python.org>
In reply to#6718
On Tue, May 31, 2011 at 1:21 AM, michal.bulla <michal.bulla@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)
<snip some obviously Django-using code>
> 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

[toc] | [prev] | [next] | [standalone]


#6730

From"bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com>
Date2011-05-31 07:28 -0700
Message-ID<25b882f1-b921-4b3c-a3e0-a7b7c248329d@s16g2000prf.googlegroups.com>
In reply to#6719
On May 31, 10:32 am, Chris Rebert <c...@rebertia.com> wrote:
> On Tue, May 31, 2011 at 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)
>
> <snip some obviously Django-using code>

Not "obviously" Django at all.

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

Arf ! I just told the guy he was on the wrong group when he
(re?)posted this on django-users.

[toc] | [prev] | [next] | [standalone]


#6955

FromCasey Dwyer <caseydwyer@gmail.com>
Date2011-06-03 09:53 -0700
Message-ID<6dc6acc6-01b1-436d-a713-8372d7e07d1c@35g2000prp.googlegroups.com>
In reply to#6718
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()

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web