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 7707249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:18:44+00:00 2026-06-01T00:18:44+00:00

I built a django site last year that utilises both a dashboard and an

  • 0

I built a django site last year that utilises both a dashboard and an API for a client.

They are, on occasion, putting unicode information (usually via a Microsoft keyboard and a single quote character!) into the database.

It’s fine to change this one instance for everything, but what I constantly get is something like this error when a new character is added that I haven’t “converted”:

UnicodeDecodeError at /xx/xxxxx/api/xxx.json

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

The issue is actually that I need to be able to convert this unicode (from the model) into HTML.

# if a char breaks the system, replace it here (duplicate line)
text = unicode(str(text).replace('\xa3', '£'))

I duplicate this line here, but it just breaks otherwise.

Tearing my hair out because I know this is straight forward and I’m doing something remarkably silly somewhere.

Have searched elsewhere and realised that while my issue is not new, I can’t find the answer elsewhere.

  • 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-06-01T00:18:45+00:00Added an answer on June 1, 2026 at 12:18 am

    I assume that text is unicode (which seems a safe assumption, as \xa3 is the unicode for the £ character).

    I’m not sure why you need to encode it at all, seeing as the text will be converted to utf-8 on output in the template, and all browsers are perfectly capable of displaying that. There is likely another point further down the line where something (probably your code, unfortunately) is assuming ASCII, and the implicit conversion is breaking things.

    In that case, you could just do this:

    text = text.encode('ascii', 'xmlcharrefreplace')
    

    which converts the non-ASCII characters into HTML/XML entities like £.

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

Sidebar

Related Questions

I have a client that has an app built with django. On every page
I've built a Django site that will live at the root when it's live.
Currently working on a site built in Django and i'm getting an issue when
I looked through the Django built-in Auth app and noticed that views are split
is there anything built-in in Django templates that will allow me to compare two
I've built a Django form that submits to a page on another domain (that
I have a website I've built in django that I'm trying to get working
I have an application that makes use of Django's UserProfile to extend the built-in
I’m implementing authentication in a Django site using the built-in auth module , including
I'm trying to generate static HTML for a site I've built in Django. What

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.