Postgres Relation Does not Exist

OK so i have the following settings and models in my django file.

Settings.py file

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'prods1',

    'USER': 'Username',

    'PASSWORD': 'Password',

    'HOST': 'localhost',

    'PORT': 5432,
}

}

Models FIle:

class Retailers(models.Model):

Links = models.CharField(max_length=500,unique=True)

Title = models.CharField(max_length=300)

Images = models.TextField()

Color = models.CharField(max_length=40)



def __str__(self):
	
	return self.Title

Now i have even entered the data into the models and have even shows it on my Test website.

but now i went to check my data on PostgreSQL (Through terminal)

But it says relation does not exist. Please Help

Screenshots For Proof:

Capitalization is significant. Compare what you’ve entered with what PostgreSQL is telling you is the name of the table. (Also note that this is not a Django issue.)

hi yes i tried without capitalization and with it, still get this error.

Well django shoes the data on the website, i was just trying to show it in my terminal, but relation does not exist :frowning:

i also deleted the database removed migrations, made the database again, and inserted data, but still same problem

Look really carefully at the capitalization of the table name compared to what you entered.

yes i tried Prods_retailers.

does not work :frowning:

Ok, do me a favor please - copy/paste the text from the \dt command as well as the text from the select statement, not an image. (It’s going to be easier to quote / demonstrate what’s happening here that way.)

Alrite, Here it is

Prods_retailers

select * from Prods_retailers;

prods1=# select * from Prods_retailers;
ERROR: relation “prods_retailers” does not exist
LINE 1: select * from Prods_retailers;

Notice what you entered vs what PSQL iterprets it as.

The PSQL docs will tell you that unquoted names are case insensitive. You need to specify the table name quoted in this case.
e.g. select * from "Prods_retailers";

prods1=# \dt
                  List of relations
 Schema |            Name            | Type  | Owner  
--------+----------------------------+-------+--------
 public | Prods_retailers            | table | firaki
 public | auth_group                 | table | firaki
 public | auth_group_permissions     | table | firaki
 public | auth_permission            | table | firaki
 public | auth_user                  | table | firaki
 public | auth_user_groups           | table | firaki
 public | auth_user_user_permissions | table | firaki
 public | django_admin_log           | table | firaki
 public | django_content_type        | table | firaki
 public | django_migrations          | table | firaki
 public | django_session             | table | firaki
(11 rows)
prods1=# select * from Prods_retailers;
ERROR:  relation "prods_retailers" does not exist
LINE 1: select * from Prods_retailers;

Sorry, timing issue - see response above your most recent comment.

1 Like

thank you thank you so much, God bless you :slight_smile: