Вопрос

I have 2 model-classes inside models.py file :

class Certificate(models.Model):
    comments = models.TextField(blank=True, default='')
    generic_certificate = models.ForeignKey(GenericCertificate, related_name='certificates_awarded')
    tag = models.ForeignKey('Tag', related_name='certificates_awarded', null=True, blank=True)


class GenericCertificate(CommonInfo):
    CERTIFICATE_TYPE = (('C', 'system created'),
                        ('U', 'user created'))

    certificate_icon = models.ImageField(upload_to='certificate/icons', default='defaults/certificate.png')
    certificate_type = models.CharField(choices=CERTIFICATE_TYPE, max_length=1, default='C')
    template = models.FileField(upload_to='certificate/generic_templates')

They are working fine in django admin , but When I am adding one more model class it starts giving error on hitting Generic certificates option: Included operation : South Migration and syncdb Exception Type: ProgrammingError Exception Value:
relation "certificates_genericcertificate" does not exist LINE 1: SELECT COUNT(*) FROM "certificates_genericcertificate"

newly added model class in same models.py

class PositionCertificate(models.Model):
    rewardee = models.CharField(max_length=50, default = '0,0')
    org_logo = models.CharField(max_length=50, default = '0,0')
    tag_name = models.CharField(max_length=50, default = '0,0') 

How to remove this error ? and why this error is coming ?

Это было полезно?

Решение

Error
relation "certificates_genericcertificate" does not exist means that "certificates_genericcertificate" relation do not exists in your database.
Please do

python manage.py syncdb

and if you are using South you can use

python manage.py migrate

try to hit these commands and if it does not help you, drop your tables/database and recreate tables/database by using syncdb.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top