By lumiobyte / Published July 21, 2019, 4:03 a.m. UTC
First and foremost, this will be a rant, kinda, and I'll probably repeat myself. If I do, skim over that maybe.
Alright, so, I'll start this by saying I am no Django expert. This blog you're reading right now is actually my first fully functional deployed Django application, with the help of a free course on Udemy. This course was about 4.5 hours of bite sized video, it explained the concepts and gave you an idea of how to use Django and create your own applications, or extend on the blog covered in the tutorial. All well and good... Until it comes time to switch debug off and deploy.
So, I chose DigitalOcean as my host of choice. Shameless referral link plug: https://m.do.co/c/362f5c9d9558 Sign Up For DigitalOcean With My Referral Link And Get $50 FREE Credit! (This is NOT sponsored btw)
Anyways, deploying seems relatively easy at first. They even have an official tutorial which guides you through server setup, installing Django, postgres, nginx, and all those fancy things which I don't understand at all. They tell you to run a few confusing commands and setup a gunicorn socket and whatever and then everything is done. But once you get to the end of that tutorial, and think, "mine doesn't look like theirs?", is when the real trouble starts.
Imagine. You've just finished the tutorial, you haven't seen any errors, and when you go to the domain, it leads to the right place. Then you notice that your images aren't displaying. And your administrator panel isn't loading properly. The tutorial has it all working correctly. You check the troubleshooting section - there is nothing there about things incorrectly displaying. You, my friend, might just have found yourself left hanging by a tutorial.
This is why I hate tutorials and guides sometimes.
They guide you through, get you so close, and then just drop you. You're a few hours away from getting your lovely app out to the world, and everything seems ready, and then you realise the guy hasn't even told you what to do when you set DEBUG = False. And honestly sure, that's okay, figure one or two things out, but when it leaves you with an entire app which "isn't deployment ready" and "this is a security risk" and THEY DON'T TELL YOU WHAT YOU CAN DO TO MAKE IT NOT A SECURITY RISK! AAAGH! anyone you ask just says "ooh yeah dont do that" and they don't actually elaborate on WHY what you're doing is bad or WHAT you can do to fix it! Aaaaagahahahjs 😡
With this blog, the hardest thing about the whole process was actually getting it online. As is the case with every web app, desktop app, mobile game, or whatever your example is. The Udemy course ended with everything working locally, on my own computer, with debug mode on. The deployment guide left me with a default Django welcome page that didn't load right. And then it left me on my own to figure out how I was going to get my app onto the server (in the end i put it in a GitHub repository and then pulled it to the server), and figure stuff out if it broke. Which is okay, and I think that is something lots of tutorials should do, but not then leave you hanging with this weird issue that nobody else seems to have... Which leads me on to my next point: DJANGO, WHY CAN'T YOU JUST DISPLAY THE IMAGES LIKE YOU DID IN DEBUG MODE!
Yes, I'm talking to you Django, and the fact that everything has the illusion of working, all the links to your images work, they display on the pages, and then when you load your app onto the server - it's all BROKEN GOD DAMMIT! Django, why are static files so confusing? Why can't you just link them up like you can every other page? Just treat them like proper documents! The html files are easy as hell to make work, and why can't the images follow the same principle!
I understand it's hard to make a good tutorial, but still...
Well that was a rant, it was long, and I probably repeated myself many times. But buried in the endless words I just wrote lies my point. If you can't tell what it is right now, you'll understand when you decide to become a Django beginner like I am right now. 😜
This is an advertisement.