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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:43:30+00:00 2026-05-21T18:43:30+00:00

Is there a way to change a CharField to a TextField and keep the

  • 0

Is there a way to change a CharField to a TextField and keep the data from this column intact?

Right now I have the following:

class TestLog(models.Model):
    failed_reqs = models.CharField(max_length=DB_MAX_CHAR_LENGTH, blank=True)
    passed_reqs = models.CharField(max_length=DB_MAX_CHAR_LENGTH, blank=True)

But the DB_MAX_CHAR_LENGTH is 500, and as it turns out this field can sometimes exceed that, so I want to go to:

class TestLog(models.Model):
    failed_reqs = models.TextField(blank=True)
    passed_reqs = models.TextField(blank=True)

How do I do this and keep my data intact on the production database?

Djangobook details how to add and remove fields, and I’ve tried using South to do this as well, but South gave me an error, and looking at the output from before the error it appears as though South is dropping and recreating the DB. Is this what south’s data migrations is all about?

  • 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-21T18:43:30+00:00Added an answer on May 21, 2026 at 6:43 pm

    Assuming that you have access to the database, as you mentioned the way Django talks about adding and removing columns, I’ve listed methods for both Postgresql and MySQL since you didn’t mention what you were using.

    Postgresql:
    BEGIN;
        ALTER TABLE "TestLog"
            ALTER COLUMN "failed_reqs" TYPE TEXT,
            ALTER COLUMN "passed_reqs" TYPE TEXT;
    COMMIT;
    
    MySQL:
    BEGIN;
        ALTER TABLE TestLog
            MODIFY failed_reqs TEXT NULL,
            MODIFY passed_reqs TEXT NULL;
    COMMIT;
    

    I would highly recommend backing up your database before doing these changes.

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

Sidebar

Related Questions

Is there any way to change(increase) the data type of a column while saving
Is there a way to change the left/right margins on a table view? The
Is there way to change the orientation of the emulator in runtime. I have
Is there a way to change a graphic, but keep the properties across frames
Is there a way to change the column headers of a SL2 datagrid during
is there a way to change the jQuery data-type: data-type=horizontal to: data-type=vertical When the
Is there a way to change values after they have been put into a
is there any way to change the status of the vm role instances from
Is there a way to change the height of a progress view bar in
Is there a way to change the 'Appearance color' (or theme) in the editor

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.