R
Railway12mo ago
ro6313

Setting up a Django admin

Hello, I am a member of the following website. I am Japanese. Sorry if my English is not good. https://railway.app/template/GB6Eki This is a Railway template that allows you to deploy "Django". I have deployed it, but I don't know the initial login name and password to enter when I go to the ADMIN page. I think I need to set up a SUPERUSER. I executed the following command, but got an "ERR" error. railway run python manage.py createsuperuser -- ERR -- ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? ---------- I haven't edited any code. Can you tell me how to set up an admin?
Solution:
Hello, I am a member of the following website. I am Japanese. Sorry if my English is not good. https://railway.app/template/GB6Eki...
Jump to solution
24 Replies
Percy
Percy12mo ago
Project ID: N/A
ro6313
ro631312mo ago
with N/A
MantisInABox
MantisInABox12mo ago
You will need to have the Railway CLI installed on your computer. You will want to follow the steps below to make it work 1) Login to Railway CLI 2) Clone the repo to local 3) pip install -r requirements.txt the project dependencies 4) railway link then select your project 5) railway service to select the service 6) railway shell to inject your service environment variables to your shell 7) railway run python manage.py createsuperuser <- to create your super user Or you can manually set all the environment variables on your virtual environment to match the ones on your django service. The choice is yours
ro6313
ro631312mo ago
Thanks for the reply. I have railway CLI installed. "railway link " succeeds, but the "railway shell" fails. [ result ] No service linked, not entering shell.
MantisInABox
MantisInABox12mo ago
I added a few missing steps. Try the above one more time in order
ro6313
ro631312mo ago
Thank you very much. I tried running it with the modified steps and got an error. Am I doing something wrong?
MantisInABox
MantisInABox12mo ago
It looks like you don't have django installed. did you do pip install -r requirements.txt? If you work on multiple python projects on your system, you should be using virtual environments for each project
Brody
Brody12mo ago
I see that is says you're missing pg_config
MantisInABox
MantisInABox12mo ago
Okay, I see what happened... Because you don't have postgres installed on your local system, it can't install postgres, and the pip install failed at the pg package
ro6313
ro631312mo ago
Yes, we did. I am getting an error "error: subprocess-exited-with-error", is this relevant?
Brody
Brody12mo ago
what os is this so we can give you the recommended installation method for postgres windows
MantisInABox
MantisInABox12mo ago
Windows Powershell Look at the prompt brody! 🤣
MantisInABox
MantisInABox12mo ago
Yeah, tell me about it! 🤣 Once you have postgres installed, you will want to run the steps again from step 3 That way it will pick up your postgres config
ro6313
ro631312mo ago
Thank you very much. I ran from step3 after installation but got another error. I will translate Japanese. "指定されたモジュールが見つかりません。" ↓ "The specified module cannot be found."
MantisInABox
MantisInABox12mo ago
That is a weird error considering, the psycopg2 package installed successfully this time.
Brody
Brody12mo ago
would it be worth a log off and log back on? what do you think vin
MantisInABox
MantisInABox12mo ago
That's a good try, and if that doesn't work, try doing pip install postgres it should install the psycopg2 and psycopg2-binary again just in case
ro6313
ro631312mo ago
Thank you! I succeeded! I rebooted and it failed. I ran "pip install postgres" and it succeeded. Thank you! Thank you very much!
Brody
Brody12mo ago
fun fact, don't run railway up
MantisInABox
MantisInABox12mo ago
No, you do not want to run railway up... That will mess things up for you
Brody
Brody12mo ago
you shouldn't even need to reboot or redoploy your service, that command just inserts data into the database, you should be able to go login right away
ro6313
ro631312mo ago
In order to deploy the original Django web app, we needed to deploy a template. Now I will be able to develop my own web app. Thank you very much.
Brody
Brody12mo ago
yep that's the beauty of templates