Once i activate models in django, why can't i query them directly in postgresql pgAdmin UI?

Question

I am very new to Django & to web programming in general. So, I apologize for the silly question. I am using django as a framework with python & I have made a connection with my database, Postgresql :

    DATABASES = {
        'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'testdb',
        'USER': 'postgres',
        'PASSWORD': '****',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

After that I ran the python manage.py migrate command & it outputted that everything was OK. I have also created models:

class Albums(models.Model):
    artist = models.CharField(max_length=250)
    album_title = models.CharField(max_length=500)
    genre = models.CharField(max_length=100)
    album_logo = models.CharField(max_length=1000)

class Song(models.Model):
    albums = models.ForeignKey(Albums, on_delete=models.CASCADE)
    file_type = models.CharField(max_length=10)
    song_title = models.CharField(max_length=250)

After that I run the commands python manage.py makemigrations, it outputs that it works. Then, I run the command python manage.py migrate & it outputs that everything is ok.

I want to know why, when I go to the database in pgAdmin & I query the data with a SELECT * FROM Albums, it does not even recognize the relation.

This is probably not the right way to test if the tables were created, but can anyone help me out and tell me why they are not created in the pgAdmin UI as well ?

Also, how can I check to see where the tables are created ?

Thank you in advance.


Show source
| python   | django   | postgresql   2016-12-28 11:12 1 Answers

Answers to Once i activate models in django, why can't i query them directly in postgresql pgAdmin UI? ( 1 )

  1. 2016-12-28 12:12

    The table name would be a bit different, it would not be the same as the model name. It would be "app_model". All the characters are lowercase. In this example, your query would be:

    SELECT * FROM 'app'_albums
    

    please replace 'app' with your app name in lower case

    As you said, you are new to web development, try

    \dt *.*
    

    This will list all the tables in your database.

Leave a reply to - Once i activate models in django, why can't i query them directly in postgresql pgAdmin UI?

◀ Go back