Skip to content
aleccool213 edited this page Dec 8, 2014 · 1 revision

There's quite a bit of overhead here for getting started. I know midterms are around the corner and that this is a lot to deal with all at once, but we've set ourselves up for a fairly easy first-iteration, so you should be able to focus the majority of your CSC301 time on getting familiar with the framework.

In order to effectively develop using Django, you'll need to do the following things:

Required

Install Python 3.4

It's probably for the best that we all use the same major release, so we don't get any weird compatibility issues.

Install Django 1.7 - https://docs.djangoproject.com/en/1.7/intro/install/

Notes:

  • You do not need to download/install Apache. The bundled development webserver should suffice for this course.
  • You do not need to setup an external database. Again, the bundled SQLite should suffice for the purposes of this course.

Recommended

Add Python 3.4 and its scripts to your PATH.

Open terminal and type 'python --version'. If you get a 2.x.x version, try 'python3 --version'

If neither of these yield python 3.4 after installing it, you'll need to add python to your path:

Windows: http://superuser.com/questions/143119/how-to-add-python-to-the-windows-path Unix/Mac generally shouldn't have this issue, though if you do, search around a bit. I might be able to help out if you can't figure it out.

Choose a Python IDE

In the grand scheme of this project, it doesn't really matter which IDE you use. You will not be running code directly from your IDE, as you will see in the Django tutorial. You'll be picking an IDE based on comfort, utility, and/or familiarity. Here are a couple possibilities:

Important: Whatever you choose, be careful of how you import the project into the IDE. You want to avoid turning into a specific IDE project, which may change the directory tree and add metadata files. You'll generally just want to import the folder for the project, and avoid things such as "Import as Django Project..." or whatever.

  • PyCharm IDE - This is probably one of the most advanced Python IDEs out there at the moment. Includes syntax highlighting, code completion, and even on-the-fly PEP8 style conformance checks. This is probably going to feel more like Eclipse and Netbeans than any other Python IDE. Community edition is free.
  • Wing IDE 101 - Probably more lightweight than PyCharm. This is what we generally used in CSC108 and CSC148, so it may be familiar to you. All standard IDE features. The 101 version may be watered down quite a bit.
  • Text Editor - If you get a good code editor such as Sublime or Notepad++, that will also suffice. I think the only annoying bit about using these is the lack of a project explorer.

Try the Django tutorial

https://docs.djangoproject.com/en/1.7/intro/tutorial01/

The tutorial should take you around 30-60 minutes, and will help familiarize you with the different systems of Django. In particular, try to solidify the Model-View-Controller web development model in your head, and understand exactly which classes are doing what. Primarily:

  • Understanding the model (models.py)
  • Understanding the view (these are the HTML templates, NOT views.py)
  • Understanding the controller (views.py)
  • Understanding the test suite (tests.py)

And most importantly understanding how these components interact with each other, and how to keep them distinct.

urls.py is a little more cryptic due to its regex, and the fact that its literally just a list, but all that really needs to be understood is that it defines which URLs will trigger each controller within views.py

As for the admin panel, I'm not entirely sure how useful that is going to be for us outside of a testing capacity. Try not to rely on it or integrate anything with it if possible.

Get some helpful HTML/CSS dev tools

We'll have to work with HTML/CSS when creating templates using Django, so having some developer tools to inspect HTML elements and modify them on-the-fly will be helpful.

Using these, you can inspect the page served by the webserver and see things like:

  • Which elements correspond to which item on the page
  • Exactly what HTML is being generated by your embedded python in templates
  • What happens when you change the source of a specific element on a page, in real-time.
Clone this wiki locally