Skip to content

Getting 'relationship does not exist' error while migrating singelton model #135

Open
@Nadir-Alishly

Description

@Nadir-Alishly

I was using sqlite3 for my database, and then I switched to postgres database, then I deleted all my migrations to start from clean sheet. Now when I run command python manage.py makemigrations I get

...
...
...
django.db.utils.ProgrammingError: relation "scholarship_scholarshipconfiguration" does not exist
LINE 1: ...larship_scholarshipconfiguration"."deadline" FROM "scholarsh...

here is my model:

from django.db import models
from solo.models import SingletonModel

class ScholarshipConfiguration(SingletonModel):
    is_active = models.BooleanField(default=False)
    application_template = models.FileField(upload_to='scholarship_templates/')
    deadline = models.DateField()

class ScholarshipApplication(models.Model):
    first_name = models.CharField(max_length=100, null=False, blank=False)
    last_name = models.CharField(max_length=100, null=False, blank=False)
    application = models.FileField(upload_to='scholarship_applications/', null=False, blank=False)

    class Meta:
        verbose_name = 'Scholarship Application'
        verbose_name_plural = 'Scholarship Applications'

and my database setups for sqlite3 and postgres:

sqlite

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

postgres

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '<dbname>',
        'USER': '<user>',
        'PASSWORD': os.environ.get('DB_PASSWORD', ''),
        'HOST': 'localhost',
        'PORT': '',
    }
}

After getting error I switched back to sqlite3 and made sure that it works on sqlite3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions