Close

Python Anywhere - Django - Git - Online Test Site

A project log for Not Just Another Coffee Table

Custom coffee table with a DCC train track, automation, LEDs and a web interface

jack-flynnJack Flynn 10/09/2018 at 10:390 Comments

Whilst working on any project it's always beneficial to get outside feedback. I'm working with my Dad on this one so we've talked a lot back and forth over the phone but sometimes it's just easier to "show" what I mean rather than tell. With this in mind I set about using the previous Django Girls Tutorial to "Deploy" my site online and create a mock up that could be viewed and interacted with without the risk of opening up my Raspberry Pi to the world wide web.  

Hosting a Django site online is essentially done by using Git to store the working files online and then passing those files to a second web server that will host the site. Python Anywhere was recommended by the tutorial and was simple enough to get setup. It runs very similar to a shell interface like working with the raspberry pi but inside your browser;

You can find the mock up of my site here. Whilst on the site if you open up the browser development tools then you can monitor the console for the debug statements coming from my java script. This lets us view how the html buttons are parsed by the javascript and what is being sent via "POST" to Django.

A final little piece I added to the site was to create a basic user for the Django admin panel. This user has the ability to add and edit the database entries for the "Trains" and "Lights" tables. If you want to play around with it then you can go to - http://jackflynn.pythonanywhere.com/admin/ - and then use the following log in details;

User - TestUser

Password - coffeetable1

Once logged in you can then change the entries in the tables or add new entries. The main page will update on a refresh and you can see for yourself how Django actively generates the html based on the database. 

Discussions