Hi, I’m trying to do a pull request to suggest some clarifying content updates of the fundraising pages of djangoproject.com.
I made it to step 3 of the README instructions.
I did make a secrets.json file in a conf directory but I’m confused about how I should fill in the placeholder info in this:
{
"secret_key": "xyz",
"superfeedr_creds": ["any@email.com", "some_string"],
"db_host": "localhost",
"db_password": "secret",
"db_user": "djangoproject",
"trac_db_host": "localhost",
"trac_db_password": "secret",
"trac_db_user": "code.djangoproject"
}
I’m assuming the secret key for this the same thing you do for making a django project you personally created? Like, can put the below in the terminal and then whatever secret key it returns should be the secret key value in the secrets.json?:
python -c "import secrets; print(secrets.token_urlsafe())"
I looked up superfeedr_creds (superfeedr.com, right?) and it looks like this is used to help with the RSS feeds maybe (is that correct?)
Regarding the superfeedr_creds, trac and non-trac database credentials: how do I go about finding/creating these?
I have done only one pull request ever, and I don’t remember doing anything like this for that one, which is just to say please feel encouraged to state what might seem obvious because I don’t know anything and any help is very much welcomed, thank you!
1 Like
I could be completely wrong, it’s been awhile since I got things set up. But the defaults should be fine for local development. If you’re not getting errors on the fundraising pages you should be fine to push a PR related to those.
2 Likes
Based on Frank’s note (thanks, Frank), I tried adding a secret key but left all the other defaults. Then I tried python manage.py runserver and that gave me a traceback, excerpt:
django.db.utils.OperationalError: connection failed: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
Wasn’t sure if that would resolve itself if I kept following the steps, so I did Step 4 (added DJANGOPROJECT_DATA_DIR=~/.djangoproject
to ~/.zshrc
).
On Step 5 (create databases), I tried to enter the four createuser
/createdb
commands into the terminal. I was asked for a password but I got this error:
createuser: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "stephaniegoulet"
I opened pgAdmin 4 settings to see if I could see anything that might help (I didn’t). I also looked in my password manager and saw that I do have a password saved as “Postgres Unix database superuser” with a note explaining that PostgreSQL prompted me to add a password, but the username isn’t “stephaniegoulet” so I was confused why the error is saying “stephaniegoulet” but I think that must be referring to my mac user name which is “stephaniegoulet”. I tried searching around more but am still struggling.
So, my questions:
- Is this
OperationalError
happening likely because I did something wrong in the previous steps or because I just haven’t done enough of the instruction setup steps?
django.db.utils.OperationalError: connection failed: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
- How do I fix this connection failure?
createuser: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "stephaniegoulet"
- is this likely happening because of using the defaults in secrets.json or is it an unrelated problem?
Any help appreciated, thanks as always.
Glad that got you further down the path. I take it you’re not using the docker compose
option here, but that error is indicating that whatever password you set for your user isn’t working. Make sure what you have in secrets.json
for db_password
matches what you used to create the user (or change the PostgreSQL user’s password to be secret
which seems to be the default).
The current setup is a bit of a mess (and iirc, the docker setup doesn’t work if you follow the instructions) and there are some improvements in PRs and other stuff that me or someone else in the Website WG has to review.
Is this OperationalError
happening likely because I did something wrong in the previous steps or because I just haven’t done enough of the instruction setup steps?
django.db.utils.OperationalError: connection failed: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
- How do I fix this connection failure?
createuser: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "stephaniegoulet"
- is this likely happening because of using the defaults in secrets.json or is it an unrelated problem?
The createuser
/createdb
commands, are Postgres commands. PostgreSQL: Documentation: 17: createuser
In this case, what I assume is happening is that your Mac user is not allowed to login to Postgres. This would depend on how postgres was installed and/or configured on your computer. This part is unrelated to the Django website, the website just expects the databases and users as indicated, but you’re failing to create them.
The secrets.json is where the db credentials for your localhost should Be. The defaults expect you to have a postgres with that combination of user/password.
1 Like
Thanks to you both for chiming in.
Correct, I’m not using the docker compose
option.
Here’s what I did next:
- Opened PgAdmin 4
- Clicked Object (in the top header menu thing)
- Clicked Properties
- Clicked Connection
- Found that the Host name/address is localhost
- Found that the Username is postgres
- Searched my password manager to see if I had anything that might be related. I found something saved as “Postgres Unix database superuser password” with “postgres” as the username and a password. It also had a note that said “when installing PostgreSQL, it asked me to “Please provide a password for the database superuser (postgres). A locked Unix user account (postgres) will be created if not present.” ; port number is “the port number the server should listen on.” (5432 was the default)”
- I opened secrets.json and updated these three credentials as follows:
"db_host": "localhost",
"db_password": "[password]",
"db_user": "postgres",
- I tried the commands again but they gave the same error.
- Instead of the instructions’ commands in Step 5, I added
-U postgres
-U docs: createuser -U postgres -d djangoproject --superuser
createdb -U postgres -O djangoproject djangoproject
createuser -U postgres -d code.djangoproject --superuser
createdb -U postgres -O code.djangoproject code.djangoproject
- I restarted pgAdmin 4 and do see two new databases there now: djangoproject and code.djangoproject so that seemed to work
- For Step 6, I replaced the instructions with (again adding -U & replacing the password):
psql -U postgres
ALTER USER djangoproject WITH PASSWORD '[password]';
ALTER USER "code.djangoproject" WITH PASSWORD '[password]';
\d
After entering the \d
, I got a return of “Did not find any relations.”
- For Step 7, I did as instructed (within the psql command-line interface). I restarted PgAdmin 4 to see if there were now any tables in the two databases, but there aren’t any. I tried it with the
-U postgres
flag as well (so psql -U postgres -d code.djangoproject < tracdb/trac.sql
) but that didn’t result in tables either. Is this related to the “”
Questions:
- I think that because there aren’t any tables in existence, that means that my problem is with
psql -d code.djangoproject < tracdb/trac.sql
; any thoughts as to what I’m doing wrong on this step? Relatedly, is it because of “Did not find any relations.”? I thought that might’ve been normal because the next step was creating tables, but maybe I’m not understanding something with that.
- Is the next command in Step 7 (
python -m manage migrate
) supposed to be run in or out of the psql command-line interface?
Update:
Between Step 6 and Step 7, you have to exit the psql interpreter (so you don’t see postgres=#
anymore) before inputting psql -d code.djangoproject < tracdb/trac.sql
Shout out @alexgmin for helping move me forward during a dsf office hours
Thanks again all; marking this post solved and I’ll post again if I run into more trouble
PS: I can’t seem to find how to mark posts solved anymore (but I know I’ve done it in the past!) so just mentioning that this is solved and if anyone can remind me how to do officially change its status to solved, happy to do that
It’s a “Category” thing. The “Django Internals” category wasn’t really intended for general q&a, so the “solved” box isn’t provided. (It’s still available in the “Using Django” category.)
1 Like