Home > Software engineering >  Create Django admin panel where project is created using another language
Create Django admin panel where project is created using another language

Time:12-23

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?

CodePudding user response:

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/

CodePudding user response:

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.

  • Related