lunes, 9 de mayo de 2011

How to install django (or run it without installing it at all) without administrative permissions

Hi!

I'm giving my first baby steps at learning Django. Right up front I saw the installation procedure and it talked about requiring an administrator to do the installation or copy the django directory inside the Djando tar ball to site-packages.... I personally don't like doing these kind of things so I sat down for a while to see how it could be done without requiring running setup.py at all. It's like this.

In my environment, I unpackaged the Django tarball that created this directory:

$ ls -l /home/antoranz/Downloads/Django/Django-1.3
total 72
-rw-r--r--  1 antoranz antoranz 19166 2011-03-21 20:38 AUTHORS
drwxr-xr-x 17 antoranz antoranz  4096 2011-05-09 09:16 django
drwxr-xr-x 14 antoranz antoranz  4096 2011-03-23 00:08 docs
drwxr-xr-x  2 antoranz antoranz  4096 2011-03-23 00:08 extras
-rw-r--r--  1 antoranz antoranz   592 2009-10-30 03:24 INSTALL
-rw-r--r--  1 antoranz antoranz  1558 2008-08-09 09:40 LICENSE
-rw-r--r--  1 antoranz antoranz  1494 2011-03-16 14:02 MANIFEST.in
-rw-r--r--  1 antoranz antoranz  1228 2011-03-23 00:08 PKG-INFO
-rw-r--r--  1 antoranz antoranz  1786 2011-01-28 17:07 README
drwxr-xr-x  2 antoranz antoranz  4096 2011-03-23 00:08 scripts
-rw-r--r--  1 antoranz antoranz   108 2010-08-05 08:00 setup.cfg
-rw-r--r--  1 antoranz antoranz  4325 2011-03-23 00:06 setup.py
drwxr-xr-x  5 antoranz antoranz  4096 2011-03-23 00:08 tests

This is the place you should run setup.py from to do django's installation, right?.... you can just skip it completely.

Now, without doing anything but just extracting the tarball, you won't be able to do much with it. From a small project I'm working on (following the tutorial):

$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 2, in
    from django.core.management import execute_manager
ImportError: No module named django.core.management

Too bad. But if you just export the PYTHONPATH to include the django directory you are done:

$ export PYTHONPATH=/home/antoranz/Downloads/Django/Django-1.3/
$ python manage.py runserver

Validating models...

0 errors found
Django version 1.3, using settings 'django1.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

And that's it. If you need to call django's binaries (django-admin.py and so on), use the full path to reach them or add the required path to PATH environment variable so that it's available.

I staill haven't tried to run django from apache without doing the instalation..... but will be publishing it (if possible) once I reach that part of the tutorial.

No hay comentarios:

Publicar un comentario