Как исправить код, чтобы всё было в порядке. Да, там куча ошибок, скорее всего, я полный ноль пока что в Django, да и в Python новичок.
from django.db import models
from django.urls import reverse
from django.utils.datastructures import DictWrapper
from django.utils.dateparse import (parse_date, parse_datetime, parse_duration, parse_time,)
import datetime
class VMs(models.Model):
ID_VM = models.BigIntegerField(primary_key=True)
UUID_VM = models.CharField(max_length=50)
VM_NAME = models.CharField(max_length=50)
BGDATE = models.DateField(auto_now_add=True)
ENDDATE = models.DateField
def __str__(self):
return '%s, %s, %s, %s' % (self.UUID_VM, self.VM_NAME, self.BGDATE, self.ENDDATE)
class VM_PARMS(models.Model):
VM_PRMS = models.BigIntegerField(primary_key=True )
TITLE = models.CharField(max_length=255)
TYPE = models.CharField(max_length=50)
class VM_STATS(models.Model):
ID_VM_STAT = models.BigIntegerField(primary_key=True)
VM_ID = models.ForeignKey(VMs, on_delete=models.CASCADE)
DATE_UPDATE = models.DateField
VM_PRMS = models.ForeignKey(VM_PARMS,on_delete=models.CASCADE)
VALUE = models.IntegerField
def __str__(self):
return '%s, %s, %s' % (self.DATE_UPDATE, self.VM_PRMS, self.VALUE)
выдаёт такую ошибку при миграции БД.
overlord@overlord ~/VMware_Analyst/VMware_Analyst $ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, catalog, contenttypes, sessions
Running migrations:
Applying catalog.0002_remove_vm_stats_value...Traceback (most recent call last):
File "/home/overlord/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "catalog_vm_stats" does not exist
Заранее спасибо всем.
сама бд выглядит так:
VMs
-
ID_VM int PK
UUID nvarchar(30)
Name nvarchar(255)
BGDATE datetime
ENDDATE datetime
VM_PARMs
-
ID_PRMS int PK
TITLE nvarchar(255)
TYPE nvarchar(20)
VM_STATs
-
ID_VMSTAT int PK
VM_ID int FK >- VMs.ID_VM
DATE datetime
VM_PARM int FK >- VM_PARMs.ID_PRMS
Value int