DeepHacks

Setting Up A Local VPS

This article details the steps of setting up a local VPS or in other words a VPS on your local computer for offline use. The virtualization software used is Virtualbox. The server is a Ubuntu LTS server installed on the Virtualbox guest machine and made accessible over a Virtualbox managed network. The end result is a server that behaves just like a cloud VPS but is local. It can be used for testing scripts and configurations or for example as a staging replacement server for offline use. It could be a cheaper alternative to a cloud VPS. Another nice side effect of having the server locally is that it's faster and that restoring the machine to its start configuration is as easy as keeping a copy of the virtual disk and copying it as needed.

Read more ...

Django And JQuery Ajax, Part 2: Forms

This article is a follow up to an article you can read here about using Django and JQuery to load paginated subpages. That article explains some of the principles that will be used again here. In this article I will show a simple way to integrate Django forms seamlessly into another page using JQuery ajax functions. The integration is kept as straightforward as possible, making sure csrf tokens, validation, error messages, and redirects work just the same way as they do on the original, non Ajax-integrated form.

Read more ...

Django Backups: dumpdata Versus SQL Dump (PostgreSQL And MySQL)

This article examines the topic of Django project data backups for the use case of restoring the data on a new server for example after a server crash or to move to a different server. When thinking about backing up your Django project data you have two options. You could use Django's own dumpdata and loaddata utilities or you could use a SQL dump of the underlying database and then restore your data from that. A third option might be to save and recover the database files directly but that won't be covered here. In this article I have a look at the first two options and discuss the pros and cons of each. For the SQL dump approach PostgreSQL and MySQL will be used as examples.

Read more ...

Django And JQuery AJAX, Part 1: Loading Paginated Subpages

This tutorial teaches a simple way to use JQuery's AJAX functionality to integrate paginated webpages, represented by Django's ListView, into the DOM of another webpage. The implementation makes very few assumptions about the included page, using its html code rather than json objects, which would require further processing. This is meant to make usage of the script very straightforward even with little knowledge of what the included webpage or its data look like. The backend is written in Django and uses some of its useful features to keep the page integration DRY and consistent. However the JQuery part by itself can be used in combination with other frameworks as well, or even with plain PHP pages. The pagination of the original, included page will be converted into an expanding list on the AJAX page, where additional pages are subsequently added to the end of the previously loaded pages. So let's get started.

Read more ...