Introduction
This article helps you set up a Python/Django project using IntelliJ 11 on a Windows 7 machine. This article assumes you have Python 2.7.2 SDK and Django 1.5 correctly set up, with all environment variables necessary.
Install Python plugin for IntelliJ
- Go to File | Settings | Plugins | Browse Repositories
- Search for Python. The latest version at the time of this post was 2.9.2. Install it.
- Restart IntelliJ when prompted.
Creating the project from scratch.
- Important! Go to File | New Project… | Create project from scratch
- If you are creating a project from existing project files, browse to the location underProject files location:
- Specify that it is a Python Module under the Select type and click Next.
- Select the python interpreter and click next.
- Select Django and input a project name, and application name.
Specifying File Types
If IntelliJ doesn’t recognize your Python file types, do the following.
- Go to File | Settings | File Types |
- Under Recognized File Types, make sure Python files has *.py and *.pyw
Specify Project Settings
- Go to File | Project Structure
- Under Project, make sure Project SDK: is Python 2.7.2 (C:/Python27/python.exe). The path might be different according to your Python27 location.
- If no SDK is specified, select New… | Python SDK |
- Browse to your python.exe file (should be something like C:\Python27\python.exe).
- All other settings in under Project do not matter. But mine were
- Project language level: 5.0 – ‘enum’ keyword, autoboxing, etc.
- Project compiler output: C:Users\rodrigo\Desktop\Projects\ssopy2\out
- Under Modules, make sure your project folder has a Django module. If it does not, add it with the [+] icon. (Important! If you did not create the project from scratch as specified above, you will not be able to add a Django module. You will have to delete this project, and go back to the top and create the project from scratch.)
- Make sure Settings: is ssopy2\settings.py (where ssopy2 is the name of your project)
- Make sure Manage script: is your manage.py file
- Under Facets, specify your Settings: and Manage script: as shown.
- Under SDKs, Select your Python 2.7.2 SDK. Make sure Name: is Python 2.7.2 (C:/Python27/python.exe). This location may be different for you.
Run/Debug Configurations
If all above was done, you shouldn’t have to configure the Run/Debug configurations. But if they do not appear already, do the following.
- Under the Run/Debug Configurations (dropdown menu next to the Run Button), select Edit Configurations…
- Add a Django server if there is not one already.
- Everything should be set up so just have to make sure the Use SDK of Module: is selected for your project. In this case, ssopy2. Press OK.