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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:21:07+00:00 2026-05-25T15:21:07+00:00

I am renaming an application to a more suitable name. In doing so, I

  • 0

I am renaming an application to a more suitable name. In doing so, I want to ensure that South properly migrates the database (renames database tables and changes references in django_content_type or south_migrationhistory). I know how to migrate a model to a different app, but when I try rename the app itself, South does not recognize the migration history properly.

Undesirable solution: In renaming old_app to new_app I could leave old_app/migrations intact and add new migrations to this directory to migrate the database to reference new_app.

If possible I would prefer to delete the directory old_app entirely. I have not yet thought of a better solution to this problem.

What is the best way to rename an app with Django South without losing data?

  • 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-25T15:21:07+00:00Added an answer on May 25, 2026 at 3:21 pm

    I agree with Laksham that you should avoid this situation. But sometimes, we have to. I’ve faced this situation in the past and I’ve managed it this way.

    If you want to avoid losing data you can dump the old application data into a json file.

    python manage.py dumpdata old_app --natural --indent=4 1> old_app.json
    

    Note the –natural option that will force the content types to be exported with their natural keys (app_name, model)

    Then you can create a small command to open this json file and to replace all the old_app references with the new_app.

    Something like this should work

    class Command(BaseCommand):
        help = u"Rename app in json dump"
    
        def handle(self, *args, **options):
            try:
                old_app = args[0]
                new_app = args[1]
                filename = args[2]
            except IndexError:
                print u'usage :', __name__.split('.')[-1], 'old_app new_app dumpfile.json'
                return
    
            try:
                dump_file = open(filename, 'r')
            except IOError:
                print filename, u"doesn't exist"
                return
    
            objects = json.loads(dump_file.read())
            dump_file.close()
    
            for obj in objects:
                obj["model"] = obj["model"].replace(old_app, new_app, 1)
    
                if obj["fields"].has_key("content_type") and (old_app == obj["fields"]["content_type"][0]):
                    obj["fields"]["content_type"][0] = new_app
    
            dump_file = open(filename, 'w')
            dump_file.write(json.dumps(objects, indent=4))
            dump_file.close()
    

    Then rename the application, change the name in INSTALLED_APPS.

    Then, you should remove all south migrations, regenerate and apply an initial migration for the new app. Then run the SQL command:

    update django_content_type set app_label='new_app' where app_label='old_app'
    

    Then launch a south migrate for the new app in order to create the tables and load the json file.

    python manage.py loaddata old_app.json
    

    I’ve done something similar on a project and it seems to work ok.

    I hope it helps

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

Sidebar

Related Questions

I'm writing an application that uses renaming rules to rename a list of files
i want to make sure that only one instance of application run... i added
I created a wonderful app, but I want to rename the application name alone...
In my Java application I am renaming files to a file name provided in
I want the exe name of an application given 'ProgramExeName + version number' at
We are thinking of renaming our web directory schema to be more user friendly.
I'd read that when renaming files in Git , you should commit any changes,
When I compile and run a web application ASP.NET appears to be renaming the
Imagine that I have a C# application that edits text files. The technique employed
My application handles with files of type *.mndl which is not more than a

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.