Setting up Django with nginx on Windows XP

To use Django need to know some basic things.

  1. What is Django, where you take and how to install?
  2. How it works Django and how it tested.
  3. What additional software and settings you should do to work properly.

What is Django, where you take and how to install?

Django is an open source web application framework. It is written in Python.

Django is available open-source under the BSD license and you can get from here.

Installation is simple, download the archive, unpack and execute the command:

How it works Django and how it tested.

Django follows the model-template-view architectural pattern.

Django focuses on automating. You can define your data models. Also, you can use Django without a database, because it comes with an object-relational mapper in which you describe your database layout in Python code.

Django has a template system, models system, system for processing requests, automatic admin interface, web templating system and more.

After installing the module can test if the module works. See picture below:

django nginx

What additional software and settings you should do to work properly.

To work, Django requires Python and Web server. You’ll need also setooptools and flup modules.

The web server can be Apache or Nginx, or other web servers.

Setting up Django with Nginx.

Web server installation and configuration.

Installing Nginx is simple, just download and unpack it on disk. I use version 1.0.5 without any problems taken from here.

The operating system was Windows XP.

After extraction of Nginx, three folders are significant: conf, HTML and logs.

In the HTML folder, we find an index file. I preferred to put here a Django project.

In the conf folder, we find the configuration files. I used the only nginx.conf file.

In the logs folder, we find the data created by the Web server.

Here are the contents of the nginx folder:

The commands to use nginx as shown below:

You will use these commands to start, stop and restart nginx web server.

You will use these commands to start, stop and restart nginx web server.

Nginx has only a few command-line parameters.

The HTML folder has two files: 50x and index.

50x file displays something like this:

Here is the content of nginx.conf my configuration file.

Installing and configuring Django framework.

After I installed Python 2.7 (this version of python I will use in this tutorial).

We will proceed with installing modules in this order: Django, setuptools and flup.

Installation went without any problems in Python 2.7 with the following modules: django – version 1.3.0 , sqlite3, setuptools-0.6c11.win32-py2.7 and flup – version 1.0.2.

Using Django involves creating a project and an application.

Django project is a collection of settings for an instance of Django

Also, Django auto-generate code to create project and applications.

Use the following command to generate the project:

Here in the picture below, the necessary elements:

The Scripts folder path where is, then the option to create a project – startproject and finally the project name – mysite.

This command generates the following files:

django nginx

The official site says that you should put script in the variable system.

I did but did not work. I had to use way to them when I run.

See, I added the system variable PYTHONPATH, these paths

django nginx

I executed the following command:

Here the picture below that worked well.

django nginx

I tested to see if I installed python SQLite module.

django nginx

I modify the file to work with SQLite and I added a database test.

django nginx

I run the following command to set and synchronize with the database.

This command looks at the INSTALLED_APPS setting and creates any necessary database tables according to the database settings in your file.

django nginx

I verified the SQLite to connect to the database.

django nginx

I create my application, make sure you’re in the mysite directory and type this command:

This command creates a directory testapp, which is laid out like in the image below.

django nginx

I added my application in the file

django nginx

To invoke the Python shell, use this command:

Next you need to activate the admin site for your installation uncomment the lines from and See image…

django nginx

Run this command to log in on admin.

This is the admin web interface. Login with the password and username created in the first part of this tutorial.

django nginx

After you login you will see the following interface:

django nginx

You can create another superuser with the command:

Here is finally content of configuration file.

As you can see we made changes in the file.

Beware any settings in, also read the documentation. For example:

“When specifying the path, always use forward slashes, even on Windows.”

There are changes to the static directory, a directory that keeps images and other files.

Run the command shown below:

django nginx

Finally you see the files copied in the folder. Look …

django nginx

Otherwise, You can see something like this:

django nginx

When you run the following command with nginx.conf and settings presented, you will see that everything works correctly as a web site.

Run the command:

You should see something like the image below:

django nginx

Because we have not created anything in addition, any HTML content. You will see something like at

django nginx

With this tutorial, I tried to present the main steps for setting up Django with nginx in Windows XP.

Since this tutorial was written experiencing may not be too accurate.

However, this tutorial contains all the information you need to do something functional.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.