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

  • Home
  • SEARCH
  • 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 8085825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:15:06+00:00 2026-06-05T18:15:06+00:00

I recently joined a company which is using django to build their product. I’m

  • 0

I recently joined a company which is using django to build their product. I’m currently responsible for one of the apps, which was already developed a little bit before I was here.

One of the entities in the app has a json dictionary attribute, which has been kept in the db as a text field. Also, this attribute is marked in the model as a text field. So, as you can imagine it’s not being handled correctly.

I wanted to change this and set it as a json field using https://github.com/bradjasper/django-jsonfield , which works really well.

However, I’ve run into a peculiar problem. Previous data stored in the db was not correctly handled and since it was unicode data, the text field in the db looks like:

{u'key': u'value'}

Now when the entity manager tries to load those values using the json field, it of course breaks since it’s no longer a valid json string.

I’ve done some research on how to overcome this, but haven’t found nothing.

My question:

Do you have any suggestion on how to overcome this? It can be any type of solution.

  • Something that I can run over night altering that field to transform it to a valid json string.
  • Some changes to the json-field code, which enables it to correctly handle these values.

Additional info

We use postgres with psycopg2 as django’s db backend.

Thank you very much.

  • 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-05T18:15:07+00:00Added an answer on June 5, 2026 at 6:15 pm

    You’re probably just going to need to iterate over the whole table, load the field, convert it into a real Python dict, and dump it back out with json.dumps. ast.literal_eval is a good choice for the conversion stage because it works like the built-in eval but is more restricted, so less risky to your system.

    for obj in MyModel.objects.all():
        value = ast.literal_eval(obj.dict_value)
        obj.dict_value = json.dumps(value)
        value.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently joined a company that using typed datasets as their 'Dto'. I
Yet another SVN guideline question, I know. I recently joined a new company which
I recently joined a company that uses codeigniter. I have been using nodejs and
I recently joined a new team. This team has been using Subversion for their
I've recently joined a company which has had a number of developers of varying
I recently joined the IT department of a big insurance company. Although the department's
I recently joined a new company with a large existing codebase. Most of my
I recently joined this organisation that I am currently working at that has asked
I recently joined a new c# project in which a console application is being
I have recently joined a team where they are using JSON serialization to pass

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.