title: django.db.utils.IntegrityError: update or delete on table when deleting a record
body: <p>I use django and postgress and have a very odd exception.
  I have a model object called ProductModel (with upc as a unique_id).
  This is how the model looks like:</p>
  
  <pre><code>class ProductModel(models.Model):
  
  def __str__(self):
      return self.clean_name + " " + str(self.product_upc)
  
  product_name = models.CharField(max_length=300, blank=True)
  product_upc = models.CharField(max_length=300, primary_key=True)
  official_price = models.DecimalField(default=0, decimal_places=5, max_digits=10)
  mrsp = models.DecimalField(default=0, decimal_places=5, max_digits=10)
  last_seen = models.DateTimeField(default=now)
  clean_name = models.CharField(max_length=200, default='')
  </code></pre>
  
  <p>unfortunately (as I understand now) at the begining of times I made a mistake and created a class called product that inherits the ProductModel - this class has some regular methods nothing fancy. </p>
  
  <pre><code>class Product(ProductModel):
  def __init__(self, *args, **kwargs):
      super().__init__(*args, **kwargs)
      self.create_clean_name()
      self.img_list = []
      self.scraped_content = ""
      self.specs = {}
  </code></pre>
  
  <p>Now, I was sure that this class has nothing to do with the db and the db doesnt aware of its existence - but now When I try to delete some product records using this command:</p>
  
  <pre><code>p = ProductModel.objects.all().filter(last_seen__month__lt=4,product_name__contains='a')
      p.delete()
  </code></pre>
  
  <p>I get the following error - </p>
  
  <pre><code>django.db.utils.IntegrityError: update or delete on table "my_app_productmodel" violates foreign key constraint "f64b7bfb6c6019a35bf6b81e4125240f" on table "my_app_product"
          DETAIL:  Key (product_upc)=(852896336240) is still referenced from table "my_app_product"
  </code></pre>
  
  <p>And in this point I got totally lost and confused what the h*** is table "my_app_product" - why it exists??
  I went to my PostgreSQL and found out that this table is really exists.
  I'd like to understand how does it work and how I delete records in this situation.
  ohh and one more detail - as I try to delete my records via django admin I manage to do it without any problems.</p>
  
  <p>Thanks to the kind helper.</p>