django.db.utils.ProgrammingError: column "Price" of relation "ogs_features_product" does not exist

  django, python

I am currenltly running django 3.1

I am trying to migrate my models.py file to postgres database. I was able to makemigrations, but when I did python manage.py migrate I got the following error.

Previously, I had a "Price" table which included "Product_ID" of "Product" table. After having issues with my models.py id’s (I have previously changed my current primary keys names you see to just id, and that caused the whole confusion), I went back to a previous version of my code that did not include "Price" table.
I was able to hop on the local server and everything, but I cannot access Customers in admin page because Customer_ID does not exist for some reason (This is in addition to not being able to migrate because of the "Price" table error!)

Is their a way to completely clean all the migrations.

models.py file

from django.db import models
from django.contrib.auth.models import User

# Create your models here.

#strong entities + many-to-one + many-to-many
class Customer(models.Model):
    Customer_ID = models.CharField(max_length = 9, primary_key = True)
    addressID = models.ManyToManyField('Address')
    First_name = models.CharField(max_length = 20, null = True)
    Middle_initial = models.CharField(max_length = 1, null = True)
    Last_name = models.CharField(max_length = 20, null = True)
    Account_Balance = models.FloatField(null = True)
    def __str__(self):
        return self.First_name + ' ' + self.Last_name

class Address(models.Model):
    Address_Title = models.CharField(max_length = 20, null = True)
    addressID = models.CharField(max_length = 9, primary_key = True)
    Street_number = models.CharField(max_length = 20, null = True)
    Street_name = models.CharField(max_length = 20, null = True)
    Apartment_number = models.CharField(max_length = 5, null = True)
    zipcode = models.CharField(max_length = 5, null = True)
    def __str__(self):
        return self.Address_Title

class Credit_Card(models.Model):
    Credit_Card_Number = models.CharField(max_length = 16, primary_key = True)
    CVV = models.DecimalField(decimal_places = 0, max_digits = 4, null = True)
    Expiration_Date = models.CharField(max_length = 10, null = True)
    Customer_Name = models.ForeignKey('Customer', on_delete=models.CASCADE, null = True)
    addressID = models.ManyToManyField('Address')
    def __str__(self):
        return self.Credit_Card_Number

class Order(models.Model):
    STATUS = (('Pending', 'Pending'), ('Out for delivery', 'Out for delivery'),('Delivered', 'Delivered'))
    Order_Number = models.CharField(max_length = 10, primary_key = True)
    Customer_Name = models.ForeignKey('Customer', on_delete=models.CASCADE, null = True)
    Credit_Card_Number = models.OneToOneField('Credit_Card', on_delete=models.CASCADE, null = True)
    Total_Price =  models.FloatField(null = True)
    status = models.CharField(max_length = 200, null = True, choices = STATUS)
    def __str__(self):
        return self.status

class Grocery_Store(models.Model):
    Grocery_Store_ID = models.CharField(max_length = 10, primary_key = True)
    addressID = models.ForeignKey('Address', on_delete=models.CASCADE)
    Grocery_Store_Name = models.CharField(max_length = 20)
    Warehouse = models.ManyToManyField('Warehouse')
    def __str__(self):
        return self.Grocery_Store_Name

class Product(models.Model):
    CATEGORY = (('Food', 'Food'), ('Drink', 'Drink'))
    Product_ID = models.CharField(max_length = 10, primary_key = True)
    Product_Name = models.CharField(max_length = 100, null = True)
    Quantity = models.IntegerField(null = True)
    Size = models.FloatField(null = True)
    Category = models.CharField(max_length = 10, null = True, choices = CATEGORY)
    Nutritional_info = models.CharField(max_length = 200)
    Product_Image = models.ImageField(null = True, blank = True)
    Grocery_Store = models.ForeignKey('Grocery_Store', on_delete=models.CASCADE, null = True,blank = True)
    Warehouse = models.ForeignKey('Warehouse', on_delete=models.CASCADE, null = True ,blank = True)
    Supplier = models.ForeignKey('Supplier', on_delete=models.CASCADE, null = True)
    def __str__(self):
       return self.Product_Name
    @property
    def imageURL(self):
        try:
            url = self.Product_Image.url
        except:
            url = ''
        return url

class Supplier(models.Model):
    Supplier_ID = models.CharField(max_length = 9, primary_key = True)
    addressID = models.ForeignKey('Address', on_delete=models.CASCADE)
    Supplier_Name = models.CharField(max_length = 20)
    def __str__(self):
        return self.Supplier_Name

class Warehouse(models.Model):
    Warehouse_ID = models.CharField(max_length = 10, primary_key = True)
    addressID = models.ForeignKey('Address', on_delete=models.CASCADE, null = True)
    Warehouse_Name = models.CharField(max_length = 20)
    Size = models.FloatField(null = True)
    available_space = models.FloatField(null = True)
    #Grocery_Store_ID = models.ForeignKey('Grocery_Store', on_delete=models.CASCADE)
    def __str__(self):
        return self.Warehouse_Name

class Staff_Member(models.Model):
    Staff_ID = models.CharField(max_length = 9, primary_key = True)
    addressID = models.ForeignKey('Address', on_delete=models.CASCADE)
    Name = models.CharField(max_length = 20)
    #Phone_Number = models.CharField(max_length = 15)
    Job_title = models.CharField(max_length = 15)
    Grocery_Store_ID = models.ForeignKey('Grocery_Store', on_delete=models.CASCADE)
    def __str__(self):
        return self.Name

Source: Python Questions

LEAVE A COMMENT