All posts tagged: django

Nginx configuration for Django

Leave a comment
Howtos / System Administration

Django is a powerful framework for building websites. To run a production website, usually an application server is used. So nginx will do two basic things: Serve your Django application from the application server port to the web port (Reverse Proxy) Serve static and media files The application server used in this example is gunicorn, the application server chosen by Instagram of the earlier days, but it can be anything running on port 9999. Change […]

Reduce Time to the First Byte – TTFB on web applications

Leave a comment
Coding / django / Python
A typical web application

How to speed up the time to the first byte and what are the causes of a long TTFB? Main causes are network and server-side and I will focus on server-side causes. I’m not covering any CMS here but you can try to apply some of these techniques starting from how to interpret the browser Timing. Get reliable timing Take a website with cache enabled: at the 9th visit on a page you can be […]

From Drupal to Django: how to migrate contents

Leave a comment
Coding / django / Drupal / Howtos / Python

In a recent article I explain the motivations for an upgrade from a no longer maintained Drupal 6 installation to Django 1.8. I will now cover more in detail the migration techniques adopted in the upgrade and I’ll deepen the models and the relationships. Structure If you’re a drupaler, you’re familiar with the node/NID/edit and the node/add/TYPE pages: Here we have two visible fields: Title and Body. One is an input type text and the other a […]

Guide to migrate a Drupal website to Django after the release of Drupal 8

comments 2
django / Drupal / Howtos

I maintain a news website written in Drupal since 2007. It is a Drupal 6, before was a 5. I made many Drupal 7 installations in these years and I went to three Drupal local conventions. This is a guide on how to abandon Drupal if you already knows some basics of Django and Python. Drupal on LAMP: lessons learned PHP is for (not so) fast development but maintainability can be a pain. Drupal try to overcome PHP limits, with […]

How to enable gzip on proxy servers on Apache

Leave a comment
Howtos / System Administration

I’m starting to use the gunicorn django app using supervisord. Here my configuration: Varnish: port 80 Apache: port 8080 gunicorn: port 4180 (/path/to/my/ run_gunicorn localhost:4180) Only the port 80 is exposed to other clients than localhost. The Varnish default backend is Apache (localhost:8080). I have a Drupal installation and a django installation on the same machine: since I want to expose django on the same domain at a defined location, I add to Apache this […]

Autolaunch a command and restart it on quit on CentOS

Leave a comment

I’ve a django-admin command running as a server thanks to gevent. I want this server to run on boot and autorestart on quit.  StackOverflow give me a hint: use Supervisor. On a Centos 5 distro: At the end of the file, add a new program: Then, start supervisord. Take a look to supervisord log file: You’ll see something like this: Read documentation about the configuration options but keep in mind your Supervisor version. I don’t […]

Django and Drupal integration using drush via SSH

Leave a comment
django / Drupal / Howtos / Python

Some months ago I talked about how to achieve a unified login from Django to Drupal using drush. The basic assumption was that both Drupal and Django are on the same server. What if the two components are on different servers? Paramiko is a SSH2 protocol library aimed to provide simple classes to make SSH connection. Let’s see how the code to call drush on command line changes. Prerequisites: paramiko on your app add: […]

Django development on Virtualbox: step by step setup

Leave a comment
Coding / django / Howtos / Python

I had a bad morning trying to repair my Cygwin installation from a virtualenv mess. It’s time to get a Debian and install it on a Virtualbox for my new django project! Windows: host Debian: guest Choosing the distro: what I want Python 2.6 Django 1.4 Apache + Mysql I’m a Debian fan from years so I go to the Debian website and download Wheezy netinst iso (32 bit, since I’m on a 32 bit OS […]