Это видео недоступно.
Сожалеем об этом.
Deploy Django App to Railway in 5 Minutes
HTML-код
- Опубликовано: 6 сен 2022
- In this tutorial, you’ll learn how to do CRUD operations using Django, Ajax. We will be using the Function Based Views Functions. We would be creating, reading (retrieving), updating (Editing) and Deleting (destroy). Did you know? CRUD operation is the most basic operation that we perform on databases. CRUD stands for Create, Read, Update, Delete. We’ll take an example of a Students Management System where we will add, update and delete students and its detail. The source code which we are building is also available on Github. Use the Link Below
.
Subscribe if you enjoyed this video for more amazing contents!!
💻 Source Code
👉 course.goprisc...
🔗 Social Medias 🔗
📱 Twitter: / desphixs
📸 Instagram: / desphixs__
⭐ Discord: / discord
📝 LinkedIn: / destiny-franks-18611120a
🌎 Website: www.desphixs.com
📂 GitHub: github.com/des...
🔊 Podcast: Coming Soon
💸 Donations 💸
💵 One-Time Donations: paystack.com/p...
💰 Patreon: www.patreon.co...
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
------------------------------------------------ About Me --------------------------------------------
My name is Destiny Franks, and I'm a Nigerian Web/Mobile App Developer. I truly enjoy coding, and since it's what I want to do in the long term, I decided to share my experience while teaching on RUclips. So, via this channel, you'd learn programming, software engineering, machine learning, and everything IT. With a focus on Python and JavaScript, my channel seeks to provide you with free tools to help you learn to code and get started in the software engineering and programming business. My goal is to deliver the best programming and technology videos on the internet!
damn it bro, the only video in all youtube that managed to explain to the letter the deployment of the app in railway without problems. thank you very much bro
You're very much welcomed brother, I'm happy to help ❤️
@@desphixs Great vid!!!
oh man.. I just tried .. it is so simple. wow thanks a lot.
Bro, it's so easy to deploy project, I'm wowed, they are the best I've seen so far
That was exactly what I was looking for... Thanks for the amazing tutorial!
Happy to help ❤️
VOCÊ É UMA LENDA. CHEERS FROM BRAZIL!!!
Amazing video brother, clear explanation Thank you!
Thanks alot pal, I'm happy to help 👍🏻❤️
Thanks! I did everything you said and it worked!
You're welcome!
Nice and clear tutorial, although the static files didn't work in my case. I had to add the WhiteNoise Middleware and all went well.
Glad it helped! ;)
me too. the static files did not work
same as to u. plase help us @desphixs
great vid helped me get my project up thank you
Allah razı olsun 10 gündür uğraşıyordum
Artık mücadele etmediğin için mutluyum dostum. Herhangi bir sorunun olursa bana ulaş
@@desphixs çok teşekkürler, tamamdır 🙏
hi, thank you for all your videos, they are so helpful. wanted to ask how would you deploy a fullstack application with both django and react? would you deploy them both on the same platform? what platform would you use? thank you sir
It depend on the platform you want to use, if you want to use AWS then yes, you can deploy the both on the same platform. Deploy Django on EC2 and react AWS Amplify
@@desphixsare there any free options like railway? if im not wrong AWS will require some cost? could you make a video on this one day sir, would be much appreciated
Thank you for the turial. I followed you deligently but mine didn't work. In my deploy log, it show:
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
/bin/bash: line 1: gunicorn: command not found
please, this is my first time deploying a webapp, I will appreciate helping me out.
Let start by checking if you have gunicorn in your requirements.txt file. Do you??
Another thing that might cause that migration error, is deleting your migration folder or Messing with it before deploying? If that's the case clone your project onto your local PC and try running it after making migration and migrate.
One more question. Did you site get deployed, like: can you visit your site now using a domain name?? Before seeing the migration error??
Thank you for creating this excellent video.
Glad you enjoyed it!
Does the web app still maintain the crud functionality if u deploy like this? Or do u have to set up a new database on railway? Awesome video. I learned a lot.
Yes, it will still maintain the CRUD functionality after deployment, but to preserve your database permanently, you will need to provision a live database
There are some stuff missing in my requirements.txt like psycopg2-binary django-etc. How to have it? Or should i type it manually??
Yes you can type it manually
Amazing video! Excelent explanation. Thank you!
You're welcome, I'm happy to help ❤️
Very good video, thanks for sharing your knowledge.
thanks alot for the comment
Thanks you helped me a lot
Glad I could help.
hey can i Up a project which contains Django+MySql as backend and Angular as frontend using this ?
Hello again! I'm having another issue with Railway. When I installed a cloudfare proxy for railway, I keep getting the error: ""SSL handshake failed Error code 525". I tried all the solutions I could find but to no avail. Any help would be appreciated.
Error code 525 in Cloudflare typically indicates that the SSL handshake between the Cloudflare proxy server and your origin server failed. This error occurs when the SSL certificate on your origin server is either missing, expired, or not configured correctly. Here are a few steps you can take to troubleshoot and resolve the issue:
1. Verify SSL certificate: Double-check that the SSL certificate on your origin server is valid and properly configured. Ensure that the certificate is not expired and matches the domain you are using.
2. Install a valid SSL certificate: If you don't have an SSL certificate installed on your origin server, you'll need to obtain one. You can either purchase an SSL certificate from a trusted certificate authority or use a free SSL certificate provider like Let's Encrypt.
3. Check SSL certificate configuration: Make sure that the SSL certificate is correctly installed and configured on your origin server. Ensure that the private key, intermediate certificates (if any), and the SSL certificate are properly set up.
4. Verify port settings: Ensure that your origin server is correctly configured to listen on the appropriate SSL/TLS port (usually port 443).
5. Firewall and security settings: Check your firewall or security settings to ensure they are not blocking the SSL handshake. Cloudflare connects to your origin server using specific IP ranges, so make sure those are not blocked by any firewall rules.
6. Cloudflare SSL/TLS settings: Double-check your SSL/TLS settings in the Cloudflare dashboard. Make sure you have selected the appropriate SSL mode (Flexible, Full, Full (Strict)) based on your origin server's SSL configuration.
7. Clear browser cache: Sometimes, the error may be caused by a caching issue. Clear your browser cache and try accessing the website again.
8. Contact Cloudflare support: If you've tried the above steps and the issue persists, reach out to Cloudflare support for further assistance. They can help diagnose the problem and provide specific guidance based on your setup.
Remember to always backup any configuration files before making changes to your server or Cloudflare settings.
Failed to load resource: the server responsed with a status of 503 (). i got his error
When do you get this error? While trying to access the site?
you need to check your deployment log to pinpoint the error
I Host my Project into railway but when I Upload files from my PC the link not find, So where are store my dynamic images and files?
You need to host your static and media files somewhere else, that's a must or else whenever you re-deploy your site, all your media files (dynamic images and files) would get deleted again.
Hello, I'm from Brazil. Thanks for the video. In deploy I have the following error message: do you know what it could be?
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: argument --error-logfile/--log-file: expected one argument
The line of code in your procfile is it correct? Error seems to be coming from there.
@@desphixs web: gunicorn projeto_open_top.wsgi --log-file-
@@desphixs look, please. Thanks
Thanks a lot. very helpful.
How to take care of environment variables (.env file).. does it require any setting in railways. assuming I will push it to github with env file.
Railway have this add variable feature, all you need to do is add your variable there e.g there would be two boxes add SECRET_KEY in the first box, then the one beside it add your secret_key_value as easy as that, you can add multiple
Great video. Just a quick question, does railway deletes static files like heroku every 24 hours like static images and sqlite3 database?
No they don't, it's remain active. But when your 500 free hour runs out, your site get disabled, you won't be able to access it again, till the next month when the 500hr get refilled again. But you can remove that limitations by verifying you account using your credit card, just make sure that: if the app you're hosting isn't that important or it's just for testing then make sure to disable it yourself or you'd run out of 500 hrs Dyno to host other apps or view hosted app till the next month.
if my api key is stored in an environment on github to avoid it being compromised, would it also be accessible on railway when i host it this way?
If you have stored your API key as an environment variable in a repository on GitHub, it is important to note that environment variables stored in a GitHub repository are not secure. When you push changes to a public GitHub repository, including environment variables, they can be accessed by anyone who has access to the repository or by automated tools that scan for exposed credentials.
When you host your application on Railway, the environment variables set in your GitHub repository will not be automatically accessible to your Railway-hosted application. Railway has its own system for managing environment variables, which is separate from the GitHub repository.
To securely manage your API key on Railway, you should use the environment variable management feature provided by Railway. This allows you to set environment variables specific to your Railway project and ensures that they are securely stored and accessible only within your Railway deployment.
Here's how you can manage environment variables on Railway:
Go to your Railway project dashboard.
Select your project.
Navigate to the "Settings" tab.
Look for the "Environment Variables" section.
Add your API key as a new environment variable.
By managing your environment variables directly within Railway, you can ensure that your API key remains secure and is not exposed in your GitHub repository, I hope this helps.
@@desphixs i can’t seem to be able to successfully open a railway account, i keep being told that I don’t have enough information of me on GitHub and they are trying to make me subscribe to the team package instead
U r tooooo good man ❤
thanks alot buddy, really means alot
Could someone help me clarify a question? I've successfully deployed my Django App on Railway using SQLite. Now, let's say a user makes a post request that updates the database. Will these changes be reflected in my GitHub repository? In other words, if I make a new push to my GitHub repo and Railway re-deploys, will it recognize that the existing database file is already up to date and avoid replacing it with the outdated one from GitHub?
Hi there, I'll be helping answer your question today.
When you deploy your website to a live server in our case railway, and a user makes a post on the live website, the post data that the user just created does not get saved in your repository and that is because GitHub is not a database system, when you deploy to railway, a "unique & free" database is assigned to your website and all new posts or comments will be saved on that database, now let's say on your live server you have gotten 35 new posts but on your local development server you have only two posts, if you make some changes to your code, push to GitHub, then deploy to railway, remember that "unique & free" database that was assigned to you? It gets deleted and a new database is assigned to the new deployment you just did.
To prevent this and always preserve your new data (posts, comment e.t.c) then you need to provision a live database e.g postgresql, connect it to your project and re-deploy. Now you'd notice that, when there is a new post or comment from users, and you make changes to your website and re-deploy, those data does not get deleted again. That's because the new database that you created is no longer for testing purposes, rather for a real website.
GitHub is only used for keeping track of your code, it's like a house holding your code and serving it to railway, then railway is reading the codes there and displaying the appropriate pages and functions e.t.c
There is still a lot more on this topic and I'll look into make a full comprehensive tutorial explaining the process of deployment in-depthly
@@desphixs I see, Thank you very much! Can I somehow download that unique & free database that was assigned to me so that I can manually push it to github?
@@huzaifafaheem6382 yes you can, but you cannot just directly download the whole db, there is a way to do it, buts it's tricky.
The best way I'd recommend is to use django_import_export package, export all the model objects (posts or comments) from the live server, import it in the local server then re-deploy again, now those files would stay there permanently.
Hey man. Thanks for this awesome tutorial! But my static files are not loading in the railway app. Can kindly show me how your {% url 'link' %} i set in templates?
My appologies for late reply, if you have not fixed this yet then let's debug it together.
1. For the url link you are talking about, {% url 'name_of_url' %} NOTE: name of url is the path(..., name="name_of_url")
2. Have you run the command *python **manage.py** collectstatic*
3. Are your static root and static url configured in settings.py and project's urls.py
Let me know if there is another issue okay?
Thank you for the video. Does the Django sqlite database get deployed to railway along w/ the app?
Yes it does, but it gets cleared after some time
@@desphixs thank you! Do I need to pay to prevent it from being cleared?
I endded up getting "Application failed to respond" page what do i do to fix it please
Check your deploy and build logs the error should be there
It is possible make working media files in deploying on railway?
Hello there, I'm finding it difficult to understand what you meant, do you mean, can you upload media files after deploying to railway?
@@desphixs exactly
Do I need to include a static file if it is just an api?
Hola, esto lo puedo con pycharm ahi tengo mi proyecto pero cuando quise hacerlo con heroku ya no era gratis y estoy buscando alternativas. Igual es mi primera vez haciendolo. Me ayudarias. Muchas gracias
Hola amigo, mis más sinceras disculpas por la respuesta tardía. Sí, por supuesto, hay alternativas a heroku, puede utilizar el ferrocarril, su plataforma de alojamiento es mucho más fácil de usar que heroku. railway.app
Hi @Desphixs I deployed my app but I am getting "gunicorn: error: argument --error-log-file: expected one argument"
Hello there, I can't see really debug the error if I can't see the full traceback or error log. Share it using pastebin or GitHub gist.
why is it saying that my github acc is not verified in the railway website?
Your GitHub account need to be at least 3 months old
it didn't work. In anyway, I need more than 500 hrs for free. The error is with Postgresql I think, "connection to server at "127.0.0.1", port 5432 failed: Connection refused". Thanks.
Hi, it is deployed but my css is not working i don't know why..
You need to run collect static command before pushing to GitHub and make sure you static url, dirs and root are configured well in the settings.py
Heyy This was a good tutorial keep it up
But how can i connect to a database like mysql, am trying but i get
(2002, "Can't connect to local server through socket '/run/mysqld/mysqld.sock'(2)")
it's very easy to connect MySQL, just create and configure the mysql in your django project, then create an instance or database for MySQL in Railway.
Facing Nixpacks build failed error
A couple of things can be causing this error, can you paste your full build log here.
Nixpacks was unable to generate a build plan for this app. How can i fix this error in Railway Buid
Have you fixed this yet??
A couple of thing might be wrong and if I can't see your code I can't really debug, seems the error is even from railway and not your code.
Is it working yet?
@@desphixs Still not working :(
Hello, thank you for this...
You're welcome ❤️
How long does it last. After that hours is runned down
20 days approximately.
Hi bro ..
Bro please help me if u can , i got error when i wanna deploy my project in railway .. it says 'Docker build failed ' .. what should i do to fix it ?
I really need it😢
send me your project link if possible, i cannot really tell what is going on.
You can also check the error and build log, copy it, paste it in pastebin.com/ and send me the error and build log, so i can debug the issue.
@@desphixs bro it's ur instagram clone project ..
But I made small changes in it.. for example, I changed the registration page and the login page, and made some changes in the frontend.. How can I give you the link? Can I give the link to the project in GitHub?
Sorry about my english bro btw😅
Amazing tutorial. Will database Read/write operations work on the deployed app or do we have to provision Postgres cloud DB instance for it?
Thanks.
The database would read and write operation as it usually happens in the development environment, but the database would get deleted after a day I think, or after your free 500hr runs out, provisioning a postgresl and connecting it is easy, I can make a tutorial if you'd watch it.
@@desphixs I will definitely watch it! It is much needed so would love it if you can make a video on it.
Hey! I have problem, i have a timeout in my logs, related to my .env file. What can I check to see where is my problem?
Have you checked your build logs??
@@desphixs yes i have timeout, and my staticfiles dont load, and the website is laggy
@@valentinfigueiredo but the website is opening up in the browser right, it's just that it's laggy?? Did you delete your media files before hosting?? To show your static files you need to run the collectstatic command and it's highly recommended that you use an external platform like aws s3 or azure to host your static and media files. Tell me if there is still any problem??
@@desphixs yes I did it in the .gitignore. No I don’t use external platform for the staticfiles , is it very usefull?
It's up to you mate, if you can afford to start using aws then go for it, else remain with railway's option
greate video bro
Thanks alot
Thx
You're welcome
Hi great video: but i have a problem: My django version is 3.11.0b5. When im trying to create a user in the django app (register user) in Railway i have an error: Origin checking failed does not match any trusted origins.
never mind i already sorted it out🙂
Great job you've done ❤️🙂
Thank you
You're very much welcomed ❤️
my deployment is stuck in building ......does anyone know why !!
Have you fixed this yet?? Check your log for errors.
@@desphixs its up and running now . I forgot the runtime file
Hey there, Desphix! Awesome video!
Unfortunately I'm having this error: "Application Error | Is your app correctly listening on $PORT? "
Can you help me?
Have you checked your build logs??
Copy and paste the build log here, so I can see what's wrong.
The error should be there.
@@desphixs The build logs is too large, so i pasted it on Google Docs docs.google.com/document/d/1qSoYA1T8sdU9mPqCo0P57iWqU6LwQ1SJKZfin0Ts_yE/edit?usp=sharing
Can you also add the deploy logs, I want to see the both.
I'm sorry, I could have told you all that at once 🙏🏿
@@desphixs Yes, for sure! Just added!
I'm having the same error! Did this get solved?
I am meeting an issue with static files. After collecting staticfiles and pushing the project to GitHub, Railway can't find the static files, even if they have been pushed on GitHub. Can anyone help me?
In local, everything is working ok.
Did you run collectstatic before pushing to GitHub?? Also I'd recommend to add whitenoise your middleware section in settings.py
@@desphixs I run collectstatic and all the staticfiles are ready in the github repo.
@@desphixs , let me call you the best. Everything is ok now after adding the whitenoise to the middleware.
thx
does this website support websocket connections???
No, it doesn't
@@desphixs thx for replying... do you any host that support Websocket connection?
thank you!
You're welcome ❤️
Thanks for the great video, unfortunately my cloudinary credentials are crashing it in the logs. Will update if I ever resolve it.
Fingers crossed! I can help if you need that...
The error is Improperly Configured. I have tried a lot of fixes but not the right one yet :)
I am not able to see a link to my generated app.
You need to generate a new custom domain from the settings
escelent video, but what about the database ?
Thanks. You could host your database on AWS and then add the DB url to Railway busing dj_database_url, i also think that railway hosts databases.
@@desphixs thanks, actually I just installed a pg database but I can't deploy psycopg or mysql dependences to my proyect
Can i edit start command ?
I would like to understand what you mean by start command??
Can I use .env with this tutorial?
It's better you use the inbuilt railway inbuilt variable config system, it's way easier and better i'd say.
@@desphixs I tried it. It worked perfectly fine. Thank you
Hi Desphix, I had an error. Anytime I try to deploy, I get this error:
Undefined is not an object (evaluating 'u.id')
How do I fix this
Never mind, I fixed it😌
Okay man, if there are any more issues, I'm always here!
Application failed to respond . this the response I got after going to website
Then there is an issue with the deploy, you need to check your deployment logs, you can copy and paste it here if you need assistance detecting the error
CSRF token not working in Railway...........how can i fix it??
Did you add the csrf_token in your form?? Or csrf_exempt in your view?
@@desphixs yes i have added csrf token in forms,,,i didn't use csrf exempt in any view,,
So after adding the csrf_token did the error persist?? If yes checkout this thread. It should give you some clue forum.djangoproject.com/t/deploy-a-django-project-on-railway-how-to-fix-the-csrf-verification-failed/16832
@@desphixs i have also added csrf trusted origin
How do i Add super user to a deployed django app deployed at railway?
You need download railway CLI. Login in this CLI and just run 'railway run ' for create super user you need 'railway run python manage.py createsuperuser'. You can see every command in docs for railway CLI
Thanks alot for answering his question.
Along side Андрей Челла's comment you can please make reference to the docs here docs.railway.app/develop/cli
@@desphixs Hi, please I installed the railway CLI but when I link my project and run "railway run python manage.py createsuperuser", it returns an error saying "python: can't open file: [Errno 2] No such file or directory
exit status 2". Any help would be appreciated.
Please I am getting 403 forbidden please how can I solve that
Do you have csrf_token in your form or csrf_exempt decorator in you view
@@desphixs yes I have csrf_token in my project
My apologies for late reply.
If you're still having the error, the checkout this thread, it should give you some clue
forum.djangoproject.com/t/deploy-a-django-project-on-railway-how-to-fix-the-csrf-verification-failed/16832
Everything worked perfectly except Django Admin panel - can't open
Can someone advise me on this it's giving Error 403 after launching the Website
So which one is the current problem now??
1. The admin issue
2. Or the 403 Error
@@desphixs Website opens perfectly but when I want to go to admin panel it asks for username and password when I type out them error 403 pops up
@@MaxWalker676 same here, when i try to log into admin panel I have this error " Forbidden (403)
CSRF verification failed. Request aborted.", tied to add CSRF_TRUSTED_ORIGINS, but it didn't fix the problem, maybe someone know how to fix this issue?
my app kept crashing
What’s the deployment error?
@@desphixs it kept crashing
@@desphixs /bin/bash: line 1: py: command not found
terrible audio, to much compression. Good explanation anyway.
Please I need you to help me with something as soon as possible
Okay I'd help if I can
What's it?
@@desphixs I need your help in migrating my site to railways
@@desphixs my system doesn't support pip update installation I need you to help me out if possible?
pls. use normal Nigerian accent bro,nice video, just stop all these ur wanna ,gonna, wanna
Alright buddy, I'll try to stop it. But I'm used to it already you know, but I'll try to.😅
Thanks alot for your comment, I really appreciate it ❤️
When you're trying to deploy an app on Railway the one time they pause deployments 🫠
If your deployment is paused then there might be an issue you can always restart your deployment
@@desphixs railway paused deployments, I wasn’t even able to connect my repo. After that was over I still wasn’t able to deploy due to my account not meeting their “criteria”.