2👍
✅
Try to remove the using
in the save:
def create_user(...):
...
user.save()
def create_superuser(...):
...
user.save()
EDIT:
Just noticed your routers don’t have db_for_write
(you wrote db_for_read
twice):
def db_for_write(self, model, **hints):
if model._meta.app_label in self.route_app_labels:
return 'users_db'
return None
0👍
Set your DataBase
like :-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'users_db',
'USER': 'postgres',
'PASSWORD': 'Trial_user123',
'HOST': 'localhost',
'PORT': '5432',
}
'content_db': {
'NAME': 'django.db.backends.postgresql_psycopg2',
'NAME': 'content_II',
'USER': 'postgres',
'PASSWORD': 'Trial_user123',
'HOST': 'localhost',
'PORT': '5432',
}
}
You have to migrate both databases differently like :-
$ ./manage.py migrate --database=users_db
$ ./manage.py migrate --database=content_II
Create a superuser
in different database like :-
./manage.py createsuperuser --database=users_db
👤Lars
- [Django]-Error adding GinIndex to model in Django with Postgres
- [Django]-Django, custom authentication login. How to display error message when authentication fails?
Source:stackexchange.com