Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nadir-Alishly opened this issue May 16, 2024 · 0 comments
Labels

Comments

@Nadir-Alishly
Copy link

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

@johnthagen johnthagen added the bug label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants