Moving from Wordpress to Django

Added 19 Jun 2023, 7:53 p.m. edited 21 Jun 2023, 11:56 a.m.

If I'm honest, I've not been happy with Wordpress for some time, however to be fair to Wordpress it does provide a good set of functionality especially for a personal website.  Looking for a replacement its all too easy to restrict your search to something with a complete set of functionality like Wordpress itself.  It took me some time of using Django at work and in private experiments before it dawned on me that Django could fill the need quite handsomely.

I did look at an add-on for Django that provides a CMS however that seemed complex and possibly more than I needed for my blog site.

Taking stock of the main features I needed, I came up with the following list.

At this point, I did think that maybe this could be a chunk of work, however as I was later to discover Django allows you develop quickly and with ease.  However its worth mentioning that this is after a somewhat steep initial learning curve, Django can be a little difficult to get to grips with, but when you do I really is worth it.

The first thing I looked at was a WYSIWYG editor, and I didn't have far to look, as Summernote fulfilled my requirements rather nicely.   I found it easy to use and it allows embedded images and even video, both from online services and some types of video files, and additionally it allows for upload-able attachments.  I'm only using the editor itself in the back-end, but it is eminently usable with a good range of features.

Implementing a search feature was almost trivial, mainly thanks to Q objects, its easy to chain these together when iterating a list created by splitting a string into words.

The CAPTCHA is something that I had previously implemented in PHP, but I decided on completely re-implementing it.  The form presents an image created on the fly from a number of smaller images, the user is asked how many of a particular image are shown.  Behind the scenes the form contains encrypted info used to check the users response, given a correct response the users email and message are stored for later viewing on the back-end.

While an RSS feed could be consider "old fashioned" it still remains a convenient and useful way for people to keep tabs on a number of websites so I wanted to continue providing this service, given the trend here you might not be surprised that again implementing this with Django was very easy with a provided class that just needed minor tailoring (overriding methods).

As I wanted an identical menu on most pages, extending from a base template made sense, the convention is to have multiple template folders for each of the projects applications, using a sub directory name for the application, these directories are in effect combined to produce a virtual file space, from which you can extend a template from another one and also include other templates too, including came in handy for example when I wanted the same block of pagination links at the top and bottom of a list.

Overall the process of replacing my admittedly simple Wordpress site, has been an easy and positive one, but moreover it leaves me in the position of having a site that is easy to extend and allows rapid development of new features.

I've often found the API provided by the core of PHP to be sprawling and sadly not terribly consistent.  In contrast I've found Python to be a much more pleasant language to code with, and this could possibly something to do with my Django itself is a powerful and obviously well thought out framework. 

I have briefly mentioned that there is an initial learning curve to Django, but rather than attempting to hit the ground running, I'd recommend of course the great tutorials on Django's website, but not just that, its very easy to spin up a new (python) virtual environment and have any number of different experiments on the go.

Its important to remember with a Django project that its built round the idea of being a group of applications, you can by all means just develop a whole site in just one application, but it's rather better to separate out distinct areas of functionality, aside from the fact you may well be able to take this functionality directly into another project, it also helps isolate different areas of a project, this separation is good practice for any number of reason, it can ease debugging and focus design for a name just two reasons.

All in all, I've very happy with Django and the numerous benefits it brings are more than worth the initial learning curve.