Create Django admin panel where project is created using another language

156 Views Asked by At

I have created a project using Golang. I have used PostgreSQL as the database. Now I want to make an admin panel for this project using Django. I want directly reflect the database tables in the Django admin panel. As I am not running the project under the Django server and I don't have any apps and models, how can I show them in the admin panel?

2

There are 2 best solutions below

0
Pablo On BEST ANSWER

What you want is to use an existing DB to be managed by the DJango admin. To do this you must create a django project and create the models for each table. This is very tedious so there is an official process so you don't have to do all this work and it is done automatically.

$ python manage.py inspectdb

https://docs.djangoproject.com/en/4.1/howto/legacy-databases/

2
n0cuous On

First create an empty project in django then in settings.py set your database as postgreSQL

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'customers',
    'USER': 'root',
    'PASSWORD': '',
    'HOST': 'localhost',
    'PORT': '5432', 
}

}

make sure to create superuser for login in admin panel and proper urls for the same.

Add models in models.py and register it in admin.py

P.S - make sure you have installed psycopg2 using pip command.