Python/Django Question

Hey,

I’ve been playing with Django and it’s pretty cool. Though I don’t know a lot about it yet. I was wondering, if your server can run Python files, can Django run?

I ask because It appears a Django application is run as a “service” by running: python manage.py startserver

Do you only need 1 copy of Django on your server to run multiple applications? When you create a project you get a folder and it looks very light, but I’m assuming it’s referencing the main Django framework.

It seems a little scary to me because I don’t understand how the Django system runs. It doesn’t look like PHP on Apache where it’s stateless until someone hits the page/directory. Rather, it appears that each application is it’s own “type of running server”.

I hope that makes sense, if anyone can answer me thanks ahead of time.

You may get the answer you seek from the developers at Plone.org http://www.plone.org ; this CMS is written in Python and utilized by government agencies such as NASA and the CIA. Many of the developers utilize Django as their Python programming framework of choice.

I’m also interested in learning Python. From what I have read thus far, developers of other languages have a harder time for Python programming is so different. However, it’s a very powerful language. Add a little Jython http://www.jython.org/ and you can do just about anything. I was told to keep an open mind and to throw out the concepts of PHP when programming in Python. It’s a steep learning curve. Stick with it! Apps written in Python are typically more secure than PHP. Good luck!

I agree, apps written in python are more secure than php. There is also ironpython which will let you interact with .NET environment and it seems to be easy to pick up if you’re newbie.

I realise that this thread is fairly old, but I thought I would provide a more detailed answer for anyone who stumbles on this in the future.


If your server can run Python scripts, then you should be able to run Django without a problem. You will however need access to configure Apache (or whatever server platform you use) to use mod_wsgi, mod_python, or FastCGI. Django and other Python frameworks are a tad different from PHP because they run as a separate process and interface with Apache, rather than being part of the Apache process itself (like PHP).

The Django framework itself is stored inside your Python installation’s site-packages directory. This directory is within the import scope of Python, so when you write “import django.x”, it is importing the appropriate module from the Django framework located in your site-packages directory. You can run multiple websites off of one Django installation, but they will have to run as separate Django instances (different instances of startserver). You can run multiple sites off of one instance, but I would not recommend this.

There are a variety of scripts to manage starting, stopping, and restarting Django instances. I personally use this one: http://code.djangoproject.com/wiki/InitdScriptForDebian

I would recommend checking out the Django documentation on deployment: http://docs.djangoproject.com/en/1.2/howto/deployment/. The information here should help anyone get started on deploying Django.