Property XXXX is not multi-line exception in python GAE

google-app-engine, google-cloud-datastore, python

Solution

The check's being done at application level, specifically in StringProperty.validate -- the code in question (which you can find in your SDK's sources in ext/db/init.py) is:

if not self.multiline and value and value.find('\n') != -1:
  raise BadValueError('Property %s is not multi-line' % self.name)

so there's no way it can be triggered unless a `\n` has indeed found its way into the `value` you're passing in. To help you debug the issue, use

logging.info('value is: %r', value)

just before the `put` that's giving you problems -- what do you see in the logs as a result? The `%r` format specifier shows the `repr` of your string, so you'll be able to observe where's the pesky `\n` that shouldn't ever be there, and, from that info, debug the issue.

Problem

I have a simple model object with ``` profilename = db.StringProperty() ``` and when I get a string with "Some More" and try to put it in model it throws exception Property profilename is not multi-line Is space equivalent to newline or I have missed something here? It is put ting for single word strings without spaces.

Original source