Django Forms, Overriding the queryset on a select field to exclude options already used.

May 6, 2019 Chris Shaw Tutorials 5709 views

In a Django form, It is posibble to override the queryset that produces the results displayed in a 'select field' from a foregin key. In this tutorial, we will pass valuse from the view to the form to build the queryset.


Setting django's static and media URLS

March 4, 2019 Chris Shaw Tutorials 7565 views

Setting your static and media urls for your django project on a shared server is simple. Make it habit to be one of the first things you do as you start a new project. All the examples in this project are for django version 2.x.


Django 2.1 and Sentry integration with Custom Error Pages.

Feb. 28, 2019 Chris Shaw Tutorials 1937 views

So you have built a Django site, the client is happy and you put it in production mode in the wild. But what if there are errors in cases that you could not even have imagined? How do you make sure you know what errors that users are experiencing? At the very least you should enable logging, with email alerts being sent for any ERROR or CRITICAL level errors. This is probably acceptable for a low traffic site. I would however reccomend using Sentry with thier powerful Djando intergration. In this tutorial, we will look at how easy it is to intergrate a free Sentry account with our project, and as a bonus, set up some custom error pages that also send logs to Sentry and even have an optional feedback form.


Connecting a django project to a shared server database

Feb. 12, 2019 Chris Shaw Tutorials 1837 views

In a previous article, I showed how to easily deploy django on a shared server. Shared servers also provide a options of database servers that you can use for your project.


Hosting your Django project with a2hosting.

Jan. 28, 2019 Chris Shaw Tutorials 2006 views

IMPORTANT UPDATE. This article is still relevent if you want to host Django 1.11 and 2.x projects. But Django 3 requires a higher version of Python. You can read my new article on how to set up Django 3 with A2 hosting here. Moving you django project from a local development environment to the open internet can be a daunting task, especially when you have a tight budget. There are free options with pythonanywhere and Heroku and probably others. For my first 'live' project, I used pythonanywhere for a while, but found it limiting. I wanted the freedom and the budget prices that shared servers offer, that I had gotten used to developing wordpress and other php based websites.