Hello, Django!

Hello, Django!

19th Jun, 2023

Wow, first ever blog! It's kind of ridiculous that somebody would think to start that only in 2023, since the cool thing to do now is to post on social media. Then again, the entire internet feels like it's falling apart now—fun!

Welp, where to start? Maybe how this page was made and the suffering I went through to get it running? sound good to me!

Why Django????

This website runs on Django, a Python framework that I went with for a few reasons.

Firstly, I love Python and how fast and easy it is to make things in it. If you need to make something using it, most likely there is a package for it out there or a guide to making it yourself.

Secondly, I wanted to try something other than Flask. While Flask is great and all, I wanted to try something else, as Flask is terribly slow at serving static files, something that'll come to bite me later.

Lastly, I don't like JavaScript, why is this important? Someone out there will tell me to have used something like Vue to make this page. My answer is no. Not every single page out there needs to be made using an entire framework, you can get the exact same results with a static HTML file and a little bit of vanilla JS.

On I love networking.

During the writing of this post, I actually experienced a lot of issues, none that Django itself caused but rather the terrible way I got everything setup. As I was setting this page up with Docker, Caddy was my proxy for my network, and it did its job for the most part. But it was very different from what I was used to with Nginx and lacked many features I wanted, such as RTMP, which it was not made for but Nginx comes with by default.

My network is also setup in a way that I have my websites running on a different container than my proxy, this is how I always had it, Nginx never complained, but oh boy, did Caddy give me a lot of issues that I'll get into in just a moment.

So, why is this an issue?

Django doesn't serve static files, the main reason being that the developers aren't interested in making a web server but a web framework. This means that Caddy had to handle the serving of static files. This is cool and all, but I've never done this before, so down a rabbit hole I went.

First I tried the obvious, getting Caddy to root the files on webserver.ip/website/static and webserver.ip/website/media. Nope! Apparently, Caddy can only serve static files from local files, not from a subdomain on a local IP. This would mean I have three options:

  1. Move Caddy onto my web server.
  2. SSH mount the files from my web server to my proxy server.
  3. Use a different proxy server.

In the end, I went with the third option, I went back to Nginx Proxy Manager (amazing tool, by the way), and setup everything from scratch again. If you are reading this, then I got everything working, yey!

Final thoughts

After all of that, switching proxies, dropping Docker, and a lot of suffering, I got this page working. Overall, would I go with Django again? Most likely! It was fast and easy to learn, and it has some really nice features. Though I wish Python was faster so I could use this for larger projects :c

While I continue to work out bugs on this page and my terrible server management, enjoy reading the slop in the blog 😋