Django Development on Windows: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 5: Line 5:


== Software ==
== Software ==
See also [[Django Development on Mac]] and [[Python Virtual Environments]]


=== Python ===
=== Python ===
Line 13: Line 15:


* [https://docs.djangoproject.com/en/1.8/topics/install/ How To Install Django] - Django Documentation (version 1.8)
* [https://docs.djangoproject.com/en/1.8/topics/install/ How To Install Django] - Django Documentation (version 1.8)
* Mac: `sudo pip install Django`<br />''N.B. The iMac that was purchased in 2015 came with python 2.x installed. I manually installed python 3.4. Typing `python` on the command line invokes python 2.x. To invoke python 3.x it's necessary to use `python3`. Similarly, `pip` will install for python 2.x, while `pip3` installs for python 3.x.''
* [http://bitnami.com/stack/django download link] (Windows)
* [http://bitnami.com/stack/django download link] (Windows)


Line 20: Line 21:
Recommended database is [http://www.postgresql.org/download/ PostgreSQL].  
Recommended database is [http://www.postgresql.org/download/ PostgreSQL].  


''(PostgreSQL is running on `littledamienii`, so this step is not necessary, actually.)''
The PostgreSQL server is running on littledamienii. It's not necessary to have a local database server.  
 
==== Mac ====


* Download the PostgreSQL installer & run it.
However, python does require the `psycopg2` package in order to connect to the database.
* Install '''pip''': `sudo easy_install pip`
* Install `psycopg2`: `pip install psycopg2`


=== Cygwin (Bash shell for Windows) ===
=== Cygwin (Bash shell for Windows) ===
Line 57: Line 54:


A lot of people simply use `vim` or notepad++. But those are simply text editors, albeit with pretty-print in the case of notepad++. They don't offer debuggers or database browsers.
A lot of people simply use `vim` or notepad++. But those are simply text editors, albeit with pretty-print in the case of notepad++. They don't offer debuggers or database browsers.
==== Windows ====


* Sublime Text
* Sublime Text


==== Mac ====
=== Articles & websites comparing Python IDEs ===
 
* Sublime Text
* Atom
* KDevelop
 
==== External Links ====


* [https://opensourcehacker.com/2015/05/02/pycharm-vs-sublime-text/ PyCharm Vs Sublime Text] - Open Source Hacker
* [https://opensourcehacker.com/2015/05/02/pycharm-vs-sublime-text/ PyCharm Vs Sublime Text] - Open Source Hacker
Line 93: Line 82:


== Notes ==
== Notes ==
* See also [[Django Development on Mac]]
<references />
<references />

Latest revision as of 17:26, 31 August 2015

Overview[edit]

Any information relevant to doing Django development on Windows.

Software[edit]

See also Django Development on Mac and Python Virtual Environments

Python[edit]

(version 2.7.3 ~3.2 is the version referenced by the current Django tutorial)[1]

Django[edit]

Database[edit]

Recommended database is PostgreSQL.

The PostgreSQL server is running on littledamienii. It's not necessary to have a local database server.

However, python does require the psycopg2 package in order to connect to the database.

Cygwin (Bash shell for Windows)[edit]

There is a local version of the distribution.

PyCharm[edit]

IDE for Django/Python development

IDE[edit]

PyCharm[edit]

I have been using PyCharm. There are other options, but this seems to offer a lot.

  • Can connect to databases from within the IDE.
  • Debugger.
  • Runs a server within the IDE for debugging purposes.
    Similar this command from the Django tutorial:
c:/myproject> python manage.py runserver 8080
  • Can create a Django project
    Analog to the following command from the Django tutorial:
c:/myproject> django-admin.py startproject mysite

Other IDEs[edit]

Notes on other IDEs as they are used or tested. Esp. any features that they offer that PyCharm does not.

A lot of people simply use vim or notepad++. But those are simply text editors, albeit with pretty-print in the case of notepad++. They don't offer debuggers or database browsers.

  • Sublime Text

Articles & websites comparing Python IDEs[edit]

Debugging[edit]

PyCharm[edit]

  • Create all Django projects to be debugged from within PyCharm:
    This will create a project environment where the PyCharm debugger can run.
    • File > New Project
    • Project name: [project name]
    • Location: [d:\path\to\parent_dir] (PyCharm will match the actual project directory name to the project name.)
    • Project type: Django Project
    • Click OK
    • Enter app name and template directory in the next dialog if desired.
    • Click OK
  • Run the debugger once the code has been added.
    • Run > Debug ProjectName
    • This will start up a server running the site on `http://127.0.0.1:8080 (or whatever port is configured in the configuration).
    • Set the appropriate breakpoints.
    • Load the site in a browser to test GET requests.
    • Run curl` to test POST requests.
    • PyCharm will stop execution at the breakpoints.

Notes[edit]