Installing MySQL, Python and Django on Windows

Here is the first part of my new and updated guide about merging GWT and Django. Enjoy!

Note 1: If Eclipse gives you the message ”GWT SDK not installed” and the GWT project can’t be built, then right click on the GWT project’s folder in the Eclipse Package Explorer and choose ”Properties”->”Java Build Path”. Enter the tab “Order and Export”. Make sure ”GWT SDK [GWT – 2.4.0]” (or whatever GWT version you want to use) is at the top of the list and that its box is marked. If ”GWT SDK [GWT – 2.4.0]” is not in the list, click on the tab Libraries and then on the button ”Add Library”. Choose Google Web Toolkit and then GWT 2.4.0 (or a later version). Finally click the ”Finish” button, and your project should be rebuilt automatically and all compilation errrors should disappear.

Note 2: Make sure Eclipse uses UTF-8 encoding for the text in the source code files if you plan to write data in the code that will be sent over to Django in UTF-8 format (e.g. text containing å, ä or ö). To do this, in Eclipse click ”Window”->”Preferences”->”General”->”Workspace” and then change ”Text file encoding” to UTF-8.


1. Install MySQL community server and MySQL Workbench using the standard alternatives except for marking ”Include Bin Directory in Windows PATH” when the option is shown. Marking that option makes it possible to interact with the database by writing ”mysql” in a terminal window or cmd.

2. Create a database and user for the MySQL database, e.g. by choosing ”New Server Instance” in MySQL Workbench (unless there already is such an instance, in that case you may use the existing one). It is also possible to perform the changes in the MySQL server by using a terminal window or cmd. In that case log in to the server by using the command “mysql -u USER_NAME -p”, alternatively “mysql -h HOST -u USER_NAME -P PORT_NUMBER -p”, where USER_NAME probably should be “root”.


3. Install Python 2.7.3 (usually this will be a 32-bit version, if you need to check during step number 6 below you can use GnuFile).

4. Add C:\Python27 and C:\Python27\Scripts to the ”path” environment variable. If you write ”python” in a new cmd-window, information about Python should now be displayed.

5. Install the Python package manager “pip” if you do not already have it. Usually this is bundled with the Python installer and can be found at C:\Python27\Scripts\pip.exe. If that is not the case, you will have to add it. This can be done in two ways. The easiest way is to follow the instructions in this link:

If that does not work, you can try the following instead: First download and install setuptools. setuptools is not compatible with Python 3.0 and above. Then install Distribute by downloading the file “” and executing it in a cmd-window. Distribute overloads the commands of setuptools with updated versions which are compatible with Python 3.0 and above. Use Distribute to download the package manager pip by writing “easy_install pip” in a cmd-window. Although this last step is probably not required to install Django (Distribute should work as well), pip is the recommended install method.

6. Download and install MySQL-Python for windows (MySQLdb) from the link below. This is required in order for Python (and therefore Django) to be able to communicate with MySQL. Choose the MySQLdb file that matches the installed version of Python (32 or 64 bit):


7. Install Django by writing “pip install django” in a cmd-window. Once it is done, check if the installation was completed successfully by writing “python” in a cmd-window, followed by “import django” and “django.VERSION”. Finally, exit Python by writing “exit()” in the cmd-window.

8. To start a new Django project, first navigate a cmd-window to the folder you want to use as the project root folder and then write “ startproject PROJECT_NAME” where PROJECT_NAME should be replaced with the name you want for the project. Avoid naming the project “test” or “django” because those names are used within Django and may cause conflicts.

 NOTE: You should never place the code of the Django project within the document root of your web server (e.g. “\var\www\”) because the code can then potentially be read by other persons over the web.

9. Navigate your cmd-window into the top catalogue of the newly created Django project (e.g. “\PROJECT_NAME\”). Use the command “python runserver” to start a test server. Make sure that the test server is working correctly by navigating to the http-adress displayed in the cmd-window (e.g. “”) with a web browser. If you yourself want to designate the port number to use for the server, use the command “python runserver NNNN”, where NNNN is the port number (e.g. 8080).

10. Open the file “PROJECT_NAME\” which should have been automatically created in the project folder. In this file you can change the Django-settings of the project. Find the variable called “ENGINE” and assign to it the value ‘django.db.backends.mysql’. Then fill in the name of the database, the username for the database and the password for the username in the corresponding fields. The variable “HOST” should be empty if the database is on the same physical machine as the server. Also change the variable “TIME_ZONE” to a suitable value, such as ‘Europe/Stockholm’. For more info about the configuration, see the Django tutorial:

 NOTE: Always use forward slashes for paths in the files of Django, even when using Windows.

11. Finally, use the command “python syncdb” to create the database tables necessary for the Django apps listed under “INSTALLED_APPS” in the file “” in the database you specified above. Answer “yes” if you get a request to create a superuser account for “authentication system”. If all tables are created successfully, the installation has succeeded. To check this, you can either look directly in MySQL Workbench or use a cmd-window. To use the latter alternative, open a cmd-window, log in to the MySQL server (see point number two under MySQL above) and then in the following order use the commands “show databases;”, “use DATABASE_NAME;” (first replace “DATABASE_NAME” with the correct name) and finally “show tables;”.


12. NOTE: In Windows Vista and 7 you need to run Eclipse as an administrator in order to be able to install plug-ins correctly through the menu alternative “Help->Install New Software…”.

First install Eclipse. Then install and configure PyDev for Eclipse according to the instructions on the PyDev website ( Finally install the GWT plug-in for Eclipse, GWT Designer for Eclipse and Smart GWT by following the instructions on their respective websites.

Browser debugging tool (Firebug)

13. In order to easier be able to read the source code, debug webpages and view complete error messages from the server while in your browser, install Firebug for Mozilla Firefox. If you prefer Chrome, I think “Chrome Developer Tools” allow you to do about the same thing.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: