Been struggling with these Django projects won't deploy. Kindly help. Please
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/opt/venv/lib/python3.11/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/venv/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/django/apps/config.py", line 178, in create
mod = import_module(mod_path)
^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1128, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pages'
[2023-07-11 13:31:27 +0000] [9] [INFO] Worker exiting (pid: 9)
[2023-07-11 13:31:28 +0000] [1] [INFO] Shutting down: Master
[2023-07-11 13:31:28 +0000] [1] [INFO] Reason: Worker failed to boot.
127 Replies
Project ID:
N/A
N/A
Could you send your code?
Runs okay locally?
Yes. It runs okay locally
So sorry for the late reply. I was still trying it. It still does not work. Here is the code repo on GutHub. https://github.com/blogy
Same as this: https://github.com/gem-inn
Could you send the repository?
That's a 404.
That's an empty profile.
I am sorry
GitHub
GitHub - maxralph1/gem-inn: Gem-Inn is an ecommerce online store fo...
Gem-Inn is an ecommerce online store for a jewelries and clothing shop crafted in Django (Python), vanilla JavaScript and Bootstrap 5.3 with online payment channels - GitHub - maxralph1/gem-inn: Ge...
GitHub
GitHub - maxralph1/blogy: BlogySocial is a SOCIAL MEDIA/BLOG applic...
BlogySocial is a SOCIAL MEDIA/BLOG application crafted in Django (python), vanilla JavaScript and Bootstrap 5.3 - GitHub - maxralph1/blogy: BlogySocial is a SOCIAL MEDIA/BLOG application crafted in...
Those 2
It is specifically refusing to deploy on Railway
Hmm, I don't really know a thing about Django, so I'm going to ping in @Vin - when you're around, would you mind helping?
I am here
Oh
you've sent two repos, do they both fail with the exact same logs?
Yes
The exact same logic
Both
I have been redoing this since yesterday. Halted everything else I was supposed to do
I think the problem is in the WSGI setup
Your Procfile says
gunicorn 'blogy.blogy.wsgi'
But if you run that command locally, you'll see the same startup error.
Fix that locally, and I expect it'll deploy correctly.At a quick glance of the blogy repo, I think I might have found the issue, but if you give me about 15 minutes, I can test to make sure that’s what the problem is.
Solution
Try this:
gunicorn --chdir blogy 'blogy.wsgi'
I have tried blogy.wsgi. It failed
Thank you so much. I am patiently waiting.
ok. I do it right away.
It didn't work instantly
FAILED
Deployment Failed during build process
That's the error message
please provide full build logs in a .txt file
ok
Hey maxralph, I tried deploying blogy from your repo after changing
Procfile
from web: gunicorn 'blogy.blogy.wsgi'
to web: gunicorn --chdir blogy 'blogy.wsgi'
-- works for me.
maybe doublecheck your changes?wow
You used Railway?
Failed the first time for be because I made a typo (blog instead of blogy), but it's working on Railway, yes
I try it right now
I hope your issue is also just a typo. Those are the worst
yeah last edit to either of those Procfiles are from yesterday
Can I send it here?
please remove any build or start commands you may have set in the service settings
no it's okay, nevermind, I'm pretty sure I know what went wrong
very important!!
I have made many commits on it. SO I had to open a new app. In fact, I recreated it from scratch, thinking it was the issue. Let me make it Public and send you the link
GitHub
GitHub - maxralph1/blogysocial
Contribute to maxralph1/blogysocial development by creating an account on GitHub.
thank you
and to double check, do you have any build or start commands defined in the service settings?
no
I am trying the latest command. it is now loading up.
Wow
No more error messages
Let me change the settings file to point to the domain
Let us see if it is the recent problem of it not showing up
So, there are a few things you can do... The easiest would be to make the Procfile change with the
--chdir
flag.
The other is a bit more involved, but is also best practice for django projects, ti move all subfolders to the root of your repo. Normally, you would not have your entire project inside of a folder. And then use a railway.json file instead of Procfile.It is finally up
I owe you all a lot!
I wish I can pay
I am using this to apply for a job
I wish you good luck!
Can't pay us directly, but you pay Railway, so that's good enough!
ANyways, there is a problem right now. It is showing my Django logic errors
When you visit your domain?
Then, you need to change your settings.py file from
DEBUG=True
to DEBUG=False
say the thing vin
You never want to deploy code in DEBUG mode
No. I only want to see if there are errors, before I turn it to False
As I am still developing it
Right, that's what you would do on local with the built-in Django server... Not on production.
Oh, is it missing the SQLite db file?
or the migrations
I thought about it, but I kept including it
looks like you need to run your migrations
I checked the miobgrations right now
It is up-to-date
If you are using SQLite, you will need to be on priority boarding, and use volumes, otherwise each deploy will destroy your database.
I would suggest switching to Postgres, or enabling volumes with priority boarding
Oh
Sorry
switch to postgres, it's just better
I saw it included in my .gitignore file
Yes. I plan to after it starts working
yes, please switch to postgres
https://github.com/railwayapp-templates/django
I would check this out too at some point for best practices on how to setup your django project on railway
And I will put all env atrributes hidden on Railway settings
Thank you
Definitely
what thing?
"switch to postgres" you said it 🙂
🤣
It's not my fault Postgres is the superior database
yes. I will. just redeployed it with the sqlite.
real
it is loading
sqlite is not postgres
I am short of words
You all will remain blessed
I am short and short of words
If you check the line of commits, it was getting out of hand. so much that I had to create another app entirely today.
I was scared that any employer seeing the main file with that many iunimportanty commits would think me reckless
That was why I opened a new repo entirely to hide my problems
The app is now running
Thank you so much once again
58 commits in total
It's development... You're going to commit bad code from time to time. It's just the nature of the beast
Plus all the commits I had to force-drop from the list on the Blogy main app
Yes. But for hosting, the employer may ask if I couldn't use a clone to test thye deployment
I understand your concern, and that's why I don't use github 🙂
use github though (do as I say not as I do)
Thank you all for your precious time. I really appreciate.
Now I have to look up how to make Postgres work on Railway, and what’s in a railway.json file.
My curiosity is piqued!
You can make an instance of it. Copy the credentials.
Also, you can think of the
railway.json
file as a new and improved Procfile
.Ok. Thank you. I just opened it.
You can set restart policy and a few other things.
Ok
Ok
I just starred it so that I can always refer to it anytime I forget after using it for these deployments.
Thank you once more. I appreciate.
Anytime.
I will leave this thread open if you do not mind
I wish to deploy my Node.JS, React.JS and Laravel apps too
yeah for sure, I'll mark as solved though
Also, I do not know if Railway accepts Phoenix framework
Because I have a little app built in it
Phoenix, with Elixr?
OK
Yes
Yeah, you should be able to deploy an Elixr app
Thank you
Elixir | Nixpacks
App source + Nix packages + Docker = Image
OK
Bookmarkedd alos. Thank you.
also*
One more question, if you have the time. I am pushing it right away with Postgres. But I must run some commands on the terminal. The command of creating a superuser. Can I also add the command to the Procfile?
It seems practically impossible
I see CLI]
You would wnat to use the railway CLI, which will inject the environment variables to your local shell. This will allow you to run the command locally, using the settings from Railway
But the documentation does not really seem straightforward enough
OK
I'll go through it again
note, this only works with postgres
Use the
railway shell
for that.Ok
PS C:\Users\maxim> railway shell
No service linked, not entering shell.
PS C:\Users\maxim> railway link
? Select a project
lively-robinpure-shirt dusty-glove [↑↓ to move, enter to select, type to filter] The 'railway link' shows up But the 'railway shell' doesn't show me nothing
firstly you need to be in your project folder
Yes
I have tried going into it
and you are not according to the text above
And when i use the command 'ls', it shows me my computer folder
I have tried cd
You need to link your project, and then do the railway shell
it CDs into my local
yes of course, this is a local shell, just with the railway service variables
I have done the link too
What Brody said
what Brody said
You cannot connect into the container
Unfortunately so
afortunately so**
How can I run Django commands?
with railway shell
You would run the railway shell, then run the Django commands like you normally would during development
No service linked, not entering shell.
run
railway service
That is what it tells me
Whenever I do 'railway shell'
^
This command showed me the project folder
But when I tried running the django commands, it failed again
You can always manually set your railway environment variables in your virtual environment on your local system. It mainly will only need your Postgres variables
Yes
But the app has to have the admin user set
OK
Wait
I just figured out something'
Since the Postgres is hosted differently and uses internet to connect, then, no problem
This will solve it
correct
Sorry. My brain has been clogged. I have been on this since morning. This is more than 15 hours now looking at the screen
Sorry about that
no worries, we all start somewhere
I’ve been there before. 20+ hours searching for misspelled variable names
the pain is real
oh
Write a script compiling all your variable names then check for common misspellings programatically