I have a well functioning remote PostgreSQL instance running in the cloud (Amazon RDS). I wanted to get a local copy for development. The remote instance is on Ubuntu and I am using postgres.app locally on a Mac. I took this approach:
psql -h localhost -U <superuser> template1 -c 'CREATE DATABASE <thedbname>;'
pg_dump -U <remoteuser> -h <remotehost> <thedbname> | psql -h localhost -U <localsuperuser> <thedbname>
The data came across and loaded up. I added a local djangouser and put it in my settings.py. When I tried to connect I was hit with this message:
ProgrammingError: permission denied for relation django_site
I searched around and then applied this:
psql <mydbname> -c "GRANT ALL ON ALL TABLES IN SCHEMA public to <djangoappusername>;"
psql <mydbname> -c "GRANT ALL ON ALL SEQUENCES IN SCHEMA public to <djangoappusername>;"
psql <mydbname> -c "GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to <djangoappusername>;"
That allows me to "runserver." I browse the site and all the data is there, it's blazingly fast and operates as expected. But then I loaded the /admin/ . . . it's DOG slow. I can login in and move around but it takes 90 seconds to move from screen to screen (Chrome shows "connecting..." in the lower left). It's not a very large DB. Everything but /admin/ access is great. I did remove the old admin.pyc, no effect.
The one thing I wonder about is the role that I used, I didn't use the remote superuser, I used the role that was created when I set up the RDS instance of PostgreSQL, this is what \\du looks like out there, and I used the first role:
List of roles
Role name | Attributes | Member of
---------------+------------------------------------------------+-----------------
<remoteuser> | Create role, Create DB | {remotesuperu}
<remotesuperu>| Cannot login | {}
<rdsadmin> | Superuser, Create role, Create DB, Replication | {}
One more thing, these are my local roles, the is the owner of the database:
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
<djangou> | Create DB | {}
<superu> | Superuser, Create role, Create DB, Replication | {}
<dbowner> | Create role, Create DB, Cannot login | {}
Anyone have any ideas on how to fix the slow admin properly, or I will happily drop the DB and bring it over again if there is a better way to do that.
I opened up developer tools, the admin was trying to fetch the css & js from the "collect static" on a remote EC2 instance that was not running. I fired it up so it can access those files and all is good. I will leave the question and answer on the off chance it helps someone in the future.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.