Blog

Efficient SQL queries with Django

Creating/fetching/saving/deleting data from database is one of the most common tasks for the the web apps. Most of the time the web app is based on database and can not work without it. Therefore developers need to remember how important is to make efficient queries and not to slow down the application as it might become really frustrating for the end user to wait ages for the page to load.

The common problem during the development is that the database contains not enough data in to notice the problem. When the app goes live and more data is being saved into the database, everything becomes slower, when that happens it’s really hard to find quick solution to the problem. The best approach is to prevent this kind of situation from the development stage, by checking how many queries particular endpoint generates and limiting them to minimum. This approach will definitely save a lot of time and money when the app goes live.

Read More (External)

Stand-alone Django script

Sometimes we need run a stand alone python script which uses the models of the Django project, let’s assume we want to run a python script in a cron job which uses our Django’s models and the setup is all within confide environment created with virtualenv. In order to achieve this the script needs to know several things. The first step is to add Django settings module to the environment inside the stand-alone script, this indicates the path to the Django projects and it’s ‘settings’. Then we need to activate the virtual environment within the script.

Read More (External)

Using HTTPS on localhost

There are several ways to run a dev server on a local machine. We can achieve this with built-in tools in the dev environment (such as ‘Django server’) or by setting up ‘nginx’ locally etc. All these solutions are awesome to use during day-to-day work and development.

However, each of these connections runs on a standard insecure HTTP protocol. Sometimes we want to work with third party services which are served by HTTPS and that we can not access without HTTPS on our server or we just simply want to test our system with a secure connection. To do this we need to enable HTTPS on our localhost. If anyone has ever tried to set it up, you may have noticed that it is not as easy as it sounds, and can be a little bit tricky.

Read More (External)