Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:35:29+00:00 2026-05-28T04:35:29+00:00

Here is model column: title = Column(Unicode(100)) When I try to add a record

  • 0

Here is model column:

title = Column(Unicode(100))

When I try to add a record to db with cyrillic letters in title I get an error:

UnicodeEncodeError:
latin-1′ codec can’t encode characters on position …

If i encode it with utf-8

title = request.POST['title'].encode('utf-8')

I get next error:

ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit btystrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

When I decode utf-8

title = request.POST['title'].decode('utf-8')

There is new error

UnicodeDecodeError: ‘ascii’ codec can’t encode characters…

What to do?

EDIT:

I’m using Sqlite3, I thought it may be important.

EDIT 2: (code and traceback)

My code:

title = request.POST['title']

new_model = Model(
    ...
    title = title,
    ...
)
DBSession.add(new_model)
DBSession.flush()

And Traceback (most recent call last):

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/performance.py”, line 55, in resource_timer_handler

result = handler(request)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/tweens.py”, line 20, in excview_tween

response = handler(request)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid_tm-0.3-py2.6.egg/pyramid_tm/init.py”, line 61, in tm_tween

response = handler(request)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/router.py”, line 164, in handle_request

response = view_callable(context, request)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/config/views.py”, line 316, in rendered_view

result = view(context, request)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/config/views.py”, line 426, in _requestonly_view

response = view(request)

File “/home/p/work/SUN/sunviver/sunviver/views/advert.py”, line 187, in create

return HTTPFound(location=new_advert.url())

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/httpexceptions.py”, line 444, in init

body_template=body_template, location=location, **kw)

File “/home/p/work/SUN/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/httpexceptions.py”, line 213, in init

Response.init(self, status=status, **kw)

File “build/bdist.linux-i686/egg/webob/response.py”, line 141, in init

setattr(self, name, value)

File “build/bdist.linux-i686/egg/webob/descriptors.py”, line 112, in fset

value = value.encode(‘latin-1’)

And new_advert.url():

def url(self):
    return '/%s/%s' % (self.id, self.title.replace(' ', '_'))

@J.F. Sebastian

Traceback (most recent call last):
File “/usr/lib/python2.6/wsgiref/handlers.py”, line 93, in run

self.result = application(self.environ, self.start_response)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/router.py”, line 187, in call

response = self.handle_request(request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/toolbar.py”, line 157, in toolbar_tween

toolbar.process_response(response)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/toolbar.py”, line 55, in process_response

vars, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 81, in render

return helper.render(value, None, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 420, in render

result = renderer(value, system_values)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 162, in call

reraise(MakoRenderingException(errtext), None, exc_info[2])

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 154, in call

result = template.render_unicode(**system)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/template.py”, line 311, in render_unicode

as_unicode=True)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 660, in _render

**_kwargs_for_callable(callable_, data))

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 692, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 718, in _exec_template

callable_(context, *args, **kwargs)

File “pyramid_debugtoolbar_templates_toolbar_mako”, line 117, in render_body

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/headers.py”, line 54, in content

vars, self.request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/init.py”, line 24, in render

return render(template_name, vars, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 81, in render

return helper.render(value, None, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 420, in render

result = renderer(value, system_values)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 162, in call

reraise(MakoRenderingException(errtext), None, exc_info[2])

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 154, in call

result = template.render_unicode(**system)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/template.py”, line 311, in render_unicode

as_unicode=True)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 660, in _render

**_kwargs_for_callable(callable_, data))

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 692, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 718, in _exec_template

callable_(context, *args, **kwargs)

File “pyramid_debugtoolbar_panels_templates_headers_mako”, line 34, in render_body

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/MarkupSafe-0.15-py2.6.egg/markupsafe/_native.py”, line 21, in escape

return Markup(unicode(s)

MakoRenderingException:

Traceback (most recent call last):

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 154, in call

result = template.render_unicode(**system)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/template.py”, line 311, in render_unicode

as_unicode=True)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 660, in _render

**_kwargs_for_callable(callable_, data))

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 692, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 718, in _exec_template

callable_(context, *args, **kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/templates/toolbar.mako”, line 61, in render_body

${panel.content()|n}

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/headers.py”, line 54, in content

vars, self.request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/init.py”, line 24, in render

return render(template_name, vars, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 81, in render

return helper.render(value, None, request=request)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/renderers.py”, line 420, in render

result = renderer(value, system_values)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 162, in call

reraise(MakoRenderingException(errtext), None, exc_info[2])

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 154, in call

result = template.render_unicode(**system)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/template.py”, line 311, in render_unicode

as_unicode=True)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 660, in _render

**_kwargs_for_callable(callable_, data))

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 692, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 718, in _exec_template

callable_(context, *args, **kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/templates/headers.mako”, line 13, in render_body

${value|h}

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/MarkupSafe-0.15-py2.6.egg/markupsafe/_native.py”, line 21, in escape

return Markup(unicode(s)

MakoRenderingException:

Traceback (most recent call last):

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid-1.3a3-py2.6.egg/pyramid/mako_templating.py”, line 154, in call

result = template.render_unicode(**system)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/template.py”, line 311, in render_unicode

as_unicode=True)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 660, in _render

**_kwargs_for_callable(callable_, data))

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 692, in _render_context

_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/Mako-0.5.0-py2.6.egg/mako/runtime.py”, line 718, in _exec_template

callable_(context, *args, **kwargs)

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.7-py2.6.egg/pyramid_debugtoolbar/panels/templates/headers.mako”, line 13, in render_body

${value|h}

File “/home/ponomar/v/ENV/lib/python2.6/site-packages/MarkupSafe-0.15-py2.6.egg/markupsafe/_native.py”, line 21, in escape

return Markup(unicode(s)

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd0 in position 7: ordinal not in range(128)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:35:29+00:00Added an answer on May 28, 2026 at 4:35 am

    Encoding converts Unicode strings to byte strings. You need to go in the other direction,
    decoding: request.POST['title'].decode('utf-8') (assuming request.POST['title'] is a UTF8-encoded str).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error: sqlite3.OperationalError: table gallery_image has no column named filename Here
here is my model class gameUserTrophyInfo(models.Model): user = models.ForeignKey(userInfo) trophy = models.ForeignKey(gameTrophyInfo) date =
Here is the model we are using to store the CC details how secure
I've got an interesting box-model problem here. I have a header full of links,
Here are the domain model classes: public abstract class BaseClass { ... } public
Here's a Django model class I wrote. This class gets a keyerror when I
Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True)
Here is a simplified version of my database model. I have two tables: Image,
Here's my code: class Publisher(models.Model): name = models.CharField( max_length = 200, unique = True,
Here's a snippet from my application: class PortolioItem(models.Model): ... user = models.ForeignKey(User) contract =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.