Deploying a Django 5 Application using PythonAnywhere
I recently developed a simple ticket tracking system in Django for my own use to better manage requests from my team at the office. It consists of two main models User and Ticket with a TicketHistory coming one of these days. The simplicity of my models led me to try using Class-Based Views for the first time and it wasn’t a bad experience coming from a few years of Function Based Views.
Staying focused on simplicity I wanted to see if I could host this basic site without standing up a new Ubuntu server instance along with the required NGINX and Gunicorn stack. I opted to give PythonAnywhere a try and I am quite pleased with the ease of deployment and performance even on the free tier.
PythonAnywhere’s Killer Feature – File Persistence
Before getting too far into this, I need to mention this app runs on a SQLite database. This was a non-starter for some app hosting providers like Heroku since there was no real file persistence. This is NOT the case with PythonAnywhere – there is a REAL live file system that is always available to your application.
Simply stated – you CAN use a file-based data source in your project.
This Elated Developer
Getting Started with PythonAnywhere
I signed up for a free user account, and got straight on about getting my application up and running.
Out of the box, PythonAnywhere supports instant setup for Django 3.X and 4.x projects. Being I was on the bleeding edge with Django 5.0.4 (Thanks Pycharm!) I had to go about setting up my environment manually.
Touching the Naughty Bits
I needed to create a my own virtual environment to run Django 5. This was as easy as could be after running a few commands in their “Console” section I was pip installing my requirements. Something PA does that I was not used to is launching virtual environments using a “workon <environment>” command. I’m guessing this might be an Anaconda method of managing virtual environments, but it was a change for me from source/bin/activate that I have become used to.
Once getting the environment setup I needed to get my code up to the site. Since I had yet to push my project to GitHub I needed to zip up my project directory and copy it up using their “Files” section. Then unzip the file in the “Console” section. After that I was a few settings changes away from rolling my app live.
After making need changes to my settings.py file and the website configuration file, I was up and running after a couple of failed starts due to my own path naming errors.
Running Live and Loving It
My simple ticketing system has been up and running for about a week at the time of writing this post and it’s utterly fantastic. Performance is great, their support seems top notch, and they are very clear that there are real developers available to help you when you need it.
Check out PythonAnywhere and see how it fits your needs.