How to display postgresql data

I am trying to create a simple dashbord that will display my data on the postgresql. In the database i have 21 columns and 5k rows of data atm. I want to connect my database to django and everytime i update the database django will recieve and update the displayed data on website. But how much I tried, I can not connect the database and if I did, I couldn’t get 5k data which is in my postgreqsl.

Is it even possible? Don’t get me wrong, I am not trying to create an empty database to use, I want to display data only.

Are you saying that you want Django to update a page without a page refresh?

How is this data being updated? Is that part of this same Django app?

It would help if you provided more details about the complete sequence of events that you envision here. What happens at each step and how those processes are “triggered” or activated.

Also, how are you envisioning this data being displayed on the website? Is it just going to be a large HTML table?

I couldn’t connect my postrgesql data with django, so I can not see my data on table in the html table. query is always empty whatever I tried. The data is going to get updated in postrgesql with python jobs. My problem is that I can not upload my data from postrge to django website.

from django.db import models


Create your models here.

class Mac(models.Model):
mac_id = models.IntegerField(db_column=‘Mac ID’, primary_key=True)
organizasyon = models.CharField(db_column=‘Organizasyon’, max_length=255, blank=True, null=True)
evsahibi = models.CharField(db_column=‘EvSahibi’, blank=True, null=True)
deplasman = models.CharField(db_column=‘Deplasman’, blank=True, null=True)
tarih = models.DateField(db_column=‘Tarih’, blank=True, null=True)
skor = models.CharField(db_column=‘Skor’, blank=True, null=True)
number_1yskor = models.CharField(db_column=‘1ySkor’, blank=True, null=True)
ms1 = models.FloatField(db_column=‘MS1’, blank=True, null=True)
msx = models.FloatField(db_column=‘MSX’, blank=True, null=True)
ms2 = models.FloatField(db_column=‘MS2’, blank=True, null=True)
number_1_5alt = models.FloatField(db_column=‘1,5Alt’, blank=True, null=True)
number_1_5ust = models.FloatField(db_column=‘1,5Ust’, blank=True, null=True)
number_2_5alt = models.FloatField(db_column=‘2,5Alt’, blank=True, null=True)
number_2_5ust = models.FloatField(db_column=‘2,5Ust’, blank=True, null=True)
number_3_5_alt = models.FloatField(db_column=‘3,5 Alt’, blank=True, null=True)
number_3_5ust = models.FloatField(db_column=‘3,5Ust’, blank=True, null=True)
number_4_5alt = models.FloatField(db_column=‘4,5Alt’, blank=True, null=True)
number_4_5ust = models.FloatField(db_column=‘4,5Ust’, blank=True, null=True)
kgvar = models.FloatField(db_column=‘KGVar’, blank=True, null=True)
kgyok = models.FloatField(db_column=‘KGYok’, blank=True, null=True)
saat = models.CharField(db_column=‘Saat’, max_length=5, blank=True, null=True)
iy0_5alt = models.FloatField(db_column=‘1y0,5Alt’, blank=True, null=True)
iy0_5ust = models.FloatField(db_column=‘1y0,5Ust’, blank=True, null=True)
iy1_5alt = models.FloatField(db_column=‘1y1,5Alt’, blank=True, null=True)
iy1_5ust = models.FloatField(db_column=‘1y1,5Ust’, blank=True, null=True)

def __str__(self):
    return self.mac_id

I presume the “NAME” is the name of the database and not the table.
‘default’: {
‘ENGINE’: ‘django.db.backends.postgresql_psycopg2’,
‘NAME’: ‘Oranlar’,
‘USER’: ‘postgres’,
‘PASSWORD’: ‘2151’,
‘HOST’: ‘localhost’,
‘PORT’: ‘5432’,

I tried to migrate and makemigrations but I couldn’t make it work either.

I tried to go with tutorials but they only show how to create an empty postrgesql database to use in django website. I will need that too but I only want to upload my data to a table on the html page right now.

In the starting stages this data is only needed to stay there, then I want users to be able to filter the values inside the table.
Basically what I imagine is below:

It sounds like you may need two database definitions here.

You need one database for your Django app. You can then define a second database to reference for this data source. See the docs at Multiple databases | Django documentation | Django.

When you’re referencing an existing table, you probably will need to use the db_table attribute of the Model’s Meta class. You would not perform any “makemigrations” or “migrate” on that external table, so you probably also want to specify managed=False.

Finally, you want to change your perspective. The database doesn’t “upload” or “push” data to Django. Django pulls data from the database. Keep that in mind as you’re thinking about how you put this together.