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
#displayapp/models.py
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.
DATABASES = {
‘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: