[Solved]-Having a separate database for django-admin in django

6👍

You talk about Authentication tables. You may declare 2 databases, the main database (‘default’) of your django app will only contains the django.contrib.auth.models models.

Your other ones will be inspected. You’ll set database name in your generated models’s admin and it should works magically.

Here how to handle multiple and configure db: https://docs.djangoproject.com/en/dev/topics/db/multi-db/

How you specify your ModelAdmin class to handle multiple database: https://docs.djangoproject.com/en/dev/topics/db/multi-db/#exposing-multiple-databases-in-django-s-admin-interface

2👍

You don’t need to create a second database. Django lets you generate models from existing tables. The documentation has a how-to for integrating existing databases: https://docs.djangoproject.com/en/dev/howto/legacy-databases/

In summary use the inspectdb management command to have Django give you models based on the existing database. You’ll still need to syncdb for the Django-specific models such as permissions and content types.

👤shanyu

Leave a comment