I'm writing an app with Django 2.1.5 using an Oracle database. The folks that maintain the database want all tables to follow a specific format, where the table is prefixed by the project name and suffixed with _TAB.

I've managed to find out, that I can set the internal table name for a Django model using the db_table attribute of the model's Metaclass. However, I can't seem to find a way to also rename the Django user, group, and permission tables.

Is there any way to rename the django.auth tables names?

1 Answers

0
user2979040 On

I found a solution, which I found in another question relating to the same topic.

The answer

from django.contrib.sessions.models import Session
Session._meta.db_table = "my_session"

Django accepted "my_session" as the internal table name, but could not find it in the database. Altering the django_session table to "my_session" made it work. This method feels more like a work-around, but it works.