dalbanhi
dalbanhi
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Hey Brody, I hope you're doing well. I had a quick question I was hoping you might be able to point me in the right direction of. I'm having some csrf troubles on my django app still (it's showing up now but I can't post anything). So, I'm trying to write to my own debugging logging file. I'm able to write to my own file on my local machine, but whenever I'm not sure where that logging file would exist on the Railway server. Would you happen to know anything about that? Any help/insight would be greatly appreciated
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
will do! Have a good night!
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Awesome! Yea, I think I'm not serving my static files for my django project correctly, but I think that's more of a django thing than a railway thing. I really appreciate all of the help, again!
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Thanks so much! After fixing some more typos, I'm getting no build nor deployment errors (I think... is it normal for a deploy log to look like this?):
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
It's truly amazing
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
I'll let you know how it goes, but I'm about to have dinner. Thank you sooo much again for all of your help
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
haha thanks
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
omg, wow, I don't know how I would have caught that. Thanks for the second set of eyes
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
So the deployment worked but I'm getting a TCP/IP connection error (log attached). I'm trying to debug the issue and any help would be appreciated!
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
hm ok. Gotcha, thanks for the tip -- I'll let you know how it goes!
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Python 3.11.8
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Ah, no I dont think I'd seen that. A useful tool
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Any help or insights at all you can point me to are super appreciated
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
It doesn't seem to have found a version of Django on my requirements.txt but I just did pip freeze > requirements.txt to save my package requirements (this is my build log):
6.026 ERROR: No matching distribution found for Django==5.0.3
6.251
6.251 [notice] A new release of pip is available: 23.0.1 -> 24.0
6.251 [notice] To update, run: pip install --upgrade pip
-----

Dockerfile:20
-------------------
18 | ENV NIXPACKS_PATH /opt/venv/bin:$NIXPACKS_PATH
19 | COPY . /app/.
20 | >>> RUN --mount=type=cache,id=s/bf770e00-35cd-438c-88ec-c9385e1bc086-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt
21 |
22 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1

Error: Docker build failed
6.026 ERROR: No matching distribution found for Django==5.0.3
6.251
6.251 [notice] A new release of pip is available: 23.0.1 -> 24.0
6.251 [notice] To update, run: pip install --upgrade pip
-----

Dockerfile:20
-------------------
18 | ENV NIXPACKS_PATH /opt/venv/bin:$NIXPACKS_PATH
19 | COPY . /app/.
20 | >>> RUN --mount=type=cache,id=s/bf770e00-35cd-438c-88ec-c9385e1bc086-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt
21 |
22 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1

Error: Docker build failed
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Hmm, so I tried this railway.json file (the one you suggested) and my build failed this time
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs"]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs"]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
(or at least the ending of it)
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Pushing [==================================================>] 94.63MB 3bea1f1ca704 Pushing [==================================================>] 96.77MB 3bea1f1ca704 Pushing [==================================================>] 98.95MB 3bea1f1ca704 Pushing [==================================================>] 101.1MB 3bea1f1ca704 Pushing [==================================================>] 103.2MB 3bea1f1ca704 Pushing [==================================================>] 105.9MB 3bea1f1ca704 Pushing [==================================================>] 106.5MB 3bea1f1ca704 Pushed 3bea1f1ca704 750024d5-965f-44e2-9fd6-d06bda6f036d: digest: sha256:9efe2f346744dc0f2552ce1a4c817d49b2c63d92a3f9f902a8ede9444b948049 size: 2421 Publish time: 9.84 seconds
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
Ok. I think it's possible my issue is this: https://www.answeroverflow.com/m/1113611990238240778 (someone very knowledgeable giving some good tips there 😉 ), so I'm going to try what you are suggesting there. I too have a package.json too because I guess I tried to make a hybrid react/django app and I'm using webpack to bundle my react files into a index-bundle.js files. In the future, I'm probably sticking with more of a cleanly split react front end / django cors framework app, but I'm digressing. Below is my build log:
183 replies
RRailway
Created by dalbanhi on 3/28/2024 in #✋|help
Trouble connecting Django to PostgreSQL database
No description
183 replies