I changed my Django App name and not DB names do not match

I am using Django and I wanted to change an app name from "project" to "projects" to make it cleaner and match the other models.

So i did the usual Django stuff. Change config name, changed config Url, change App folder name. Even changed the apps.py and the urls to app_name = 'projects'

The migrations went ok.

Issue is the database is still showing everything as project_*** in the database.

enter image description here

So now I am getting errors like these:

** error relation "projects_overview" does not exist

LINE 1: SELECT "projects_overview"."a_id" FROM "projects_overview"

It wants the new "S".

how can I get the database to show the correct prefix of projects_ and not the old project_?

will I have to use Postgres commands to change all the tables manually or did I miss some Django command.

DBs are not my thing so very greatful for anyones kind help. Thank you.

The table name you sould change accordingly. Something like

alter table project_overview rename...

ALTER TABLE

project_overview

RENAME TO

projects_overview

;

You can provide a custom table name in the model using the metaclass before changing the app name, so that it won't conflict with the app name

class MyModle:
    class Meta:
        db_table = "custom_table_name"

Note:

You have to do this before changing the app name. Else you have to manually change each table name in the database, or you have to write custom migration to reanme the tables with the new app name.

Back to Top