GithubHelp home page GithubHelp logo

meshy / app-rename-example Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 5.0 22 KB

A commit-by-commit example of how to rename a django app.

Home Page: https://stackoverflow.com/a/51581569/400691

Python 100.00%

app-rename-example's Introduction

Rename app from shop to catalogue

This repo shows how you can rename a django app.

Read through the commits to see how the following steps were completed.

Steps:

  • Prepare existing setup for move:
    • Create an app config (set name and label to defaults).
    • Add the app config to INSTALLED_APPS.
    • On all models, explicitly set db_table to the current value.
    • Doctor migrations so that db_table was "always" explicitly defined.
    • Ensure no migrations are required (checks previous step).
  • Change app label:
    • Set label in app config to new value (catalogue).
    • Update migrations and foreign keys to reference new app label.
    • Run custom SQL to fix migrations and content_types app.
      UPDATE django_migrations
         SET app = 'catalogue'
       WHERE app = 'shop';
      
      UPDATE django_content_type
         SET app_label = 'catalogue'
       WHERE app_label = 'shop';
    • Ensure no migrations are required (checks previous step).
  • Rename tables:
    • Remove "custom" db_table.
    • Run makemigrations so django can rename the table "to the default".
  • Move the files:
    • Rename module directory.
    • Fix imports.
    • Update app config's name.
    • Update where INSTALLED_APPS references the app config.
  • Tidy up:
    • Remove custom app config if it's no longer required.
    • If app config gone, don't forget to also remove it from INSTALLED_APPS.

app-rename-example's People

Contributors

meshy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

app-rename-example's Issues

Getting Rename table for task to (default) for one model

I have followed the process but getting Rename table for task to (default) for a particular Task model. I have lots of migrations and around 10 models. 9 models worked but this one giving me one migrations. Suggest what to do.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.