0

I need to develop a new django project (let's call it new_django) using a SQL Server 2019 database named AppsDB which already hosts another django project (let's call it old_django). The two apps are completely separate from each other. Unfortunately, I can't get a new database for each new django project, so I have to reuse AppsDB. What I don't understand is, how can I tell django not to overwrite the existing auth_... and django_... tables generated by old_django?

My first idea was to use different schemas for the two project, but django doesn't support this with a SQL Server database as far as I know. Some workarounds suggest to change the database default schema for a given user like this anwser. But I won't get a new user for every project either. And relying on manually changing the db schema every time before I migrate something will most certainly cause a mess at some point.

I'm stuck with the current setup and would like to know if anyone has come up with a more elegant solution or different approach to solve my problem?

Any help is much appreciated!

N. Maks
  • 539
  • 3
  • 15

1 Answers1

0

All you need to do is to create a new database in mssql server and then point your django application on the database server like this below.

DATABASES = {
    'default': {
        'ENGINE': 'mssql',
        'NAME': 'YOU_DATABASE_NAME',
        'USER': 'DB_USER',
        'PASSWORD': 'DB_PASSWORD',
        'HOST': 'YOUR_DATABASE_HOST',
        'PORT': '',
        'OPTIONS': {
            'driver': 'ODBC Driver 13 for SQL Server',
        },
    }
}
romel rada
  • 21
  • 4