abidibo.net

Just Open Source

Posted in "django"

Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric, part 3

deploy django nginx programming wsgi

This is the third part of the django deploy environment, you may find the second part here.

In this part we'll see how to set up nginx and uwsgi to work with our django project.

Let's install and configure uwsgi

Be sure to have the virtualenv activated (see part 2), and then install uwsgi

$ pip install uwsgi

Ok now we have to configure our project to work with uwsgi, open and edit the myproject/myproject/wsgi.py file, mine looks like this:

"""
WSGI config for sic2012 project.

This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.

Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.

"""
import os ...

read the full post


Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric, part 2

deploy django programming south virtualenv

Ok, this is the second part of the django deploy environment, you may find the first part here.

In the prevoius post we have seen how to install nginx webserver an some system packages, both in locale and remote, now it's time to start our developement in locale.

Let's create a new virtualenv

The use of virtualenv is incredibly comfortable and lets you keep separated environment for different projects. So first of all create a new virtualenv in the place you prefer

$ mkdir ~/virtualenv
$ cd ~/virtualenv
$ virtualenv --no-site-packages myproject

Done, now we can activate the virtualenv so that every new python package will be installed in it, so

$ source ~/virtualenv/myproject/bin/activate

MySQL as the database server

Why MySQL? Only because I'm easy with it, I know its syntax, I'm accustomed with it and because I use it at work.
But, since the role of mysql in the whole deploy structure finishes here, you may want to use a different db server, more efficient, lightweight and which uses less system resources

In the first post ...

read the full post


Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric, part 1

deploy django nginx programming virtualenv

After googling for a while, asking my guru and some tests I was able to setup a deploy environment for django projects.

The web server is nginx, the database server mysql, I use uwsgi as wsgi server, all the code is versioned using git, the python libraries are installed in a virtualenv, db migration is assured by South and the deploy is automated using fabric.

While writing this post the whole environment is working but I think it may be adjusted in some ways, so let's take what follows as a guideline to improve in many aspects.

I assume we are working in locale and deploying directly to a production server, ignoring the staging phase.

Installing some packages (locale and remote)

To set up the environment we need python >= 2.6, python-dev, python-setuptools, pip and virtualenv, so (in a debian/ubuntu os):

$ sudo apt-get install python python-dev python-setuptools
$ sudo easy_install pip
$ pip install virtualenv

Ok that's all, the other python packages will be installed in the virtualenv, so now let's continue installing git and mysql

$ sudo apt-get install git ...

read the full post


HowTo tree like ordering in django admin changelist view

django django-admin

Premetto che questo è il frutto di almeno 6 ore di delirio. Chiaro I'm a newbie in django developement, ma cazzo quanto ho sudato, inoltre questo problema mi ha indotto a spulciare molte porzioni di codice del core di django, estendere viste, manager, costruire template tags, ed alcune di queste cose neanche sapevo esistessero,.. ne consegue un post delirante, prolisso e a tratti ripetitivo in cui cerco di spiegare e spiegarmi alcuni aspetti del funzionamento della admin di django.
Tra l'altro seguo premettendo che essendo ancora un pippone di django scriverò qui alcune banalità e probabilmente molte imprecisioni, ma me ne fotto, Cerco di spiegare con parole semplici quello che ho capito, o anche solo intuito, e non approfondito per ...

read the full post


HowTo install django-filer

django django-filer pip

Qualunque applicazione di stampo editoriale (blog, flatpages, ...) deve poter permettere di inserire all'interno dei contenuti una o più risorse multimediali, allegati e quant'altro.

Uno modo per affrontare questa necessità è quello di crearsi una app di tipo "allegati" che permetta la gestione di upload ed alcune normali operazioni su filesystem direttamente sul server. In questo modo potremo poi linkare le nostre risorse in qualunque altra app della nostra applicazione.

Da qui la necessità di sviluppare o utilizzare un filemanager per la sezione amministrativa di django che permetta la gestione di files e immagini.
Io ho scelto avevo scelto di utilizzare django-filer, un'applicazione presente su github ancora in fase di aggiornamento.

Allora semplicemente questa vuole essere una guida ...

read the full post


Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured