Django PostgreSQL DatabaseError: category relationships do not exist

I am working on a Django application. I originally used MySQL for the database. Then I needed to deploy a demo application on heroku that uses PostgreSQL.

I get an error in heroku when I try to create an object, even from a shell.

This is what I am trying to do:

>> from store.models import Product, Category >> cat = Category() >> cat.name = 'books' >> cat.description = 'books' >> cat.slug = 'books' >> cat.save() 

I get the following error:

 ...... DatabaseError: relation "categories" does not exist 

Here are my models of categories and products.

 class Category(models.Model): name = models.CharField(max_length=50) description = models.TextField() slug = models.SlugField(max_length=50, unique=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Product(models.Model): name = models.CharField(max_length=100, unique=True) description = models.TextField() price = models.DecimalField(max_digits=9, decimal_places=2) slug = models.SlugField(max_length=50, unique=True) categories = models.ManyToManyField(Category) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) 

It works fine with MySQL, but not with PostgreSQL.

Can anyone help?

Thanks.

+4
source share
1 answer

You need to run syncdb in heroku so that it installs your application and models.

 heroku run python manage.py syncdb 

If you made changes to your scheme and use the south, then:

 heroku run python manage.py schemamigration appname --auto 
+6
source

All Articles