Project layout

The project layout was made in such a way that code is seperated from non-code files that you typically want to serve in another way (static and media files) or keep in a different location (like the virtual environment):

+-- env                 -- Virtual environment files.
+-- src                 -- Container for one or more source directories.
|   |
|   +-- codelinker
|       |
|       +-- conf        -- Django settings files.
|       |
|       +-- templates   -- Project templates
|       |
|       +-- wsgi        -- Default location for wsgi deployment scripts
|       |
|       +-- static      -- Default location for project static files
|       |
|       +-- ...         -- Project specific applications.
+-- static              -- Default location for collected static files.
+-- media               -- Default location for uploaded media files.
+-- log                 -- All log files generated by the project.
+-- doc                 -- Documentation source and generated files.
+-- requirements        -- Project requirements for each type of installation.


New installations (for development or production) should follow the steps below.

  1. Navigate to the location where you want to place your project.

  2. Get the code:

    $ git clone ssh://
    $ cd codelinker
  3. Bootstrap the virtual environment and install all required libraries. The script basically sets the proper Django settings file to be used:

    $ python <production|staging|test|development>
  4. Activate your virtual environment and create the statics and database:

    $ source env/bin/activate
    $ python src/ collectstatic --link
    $ python src/ migrate


Optionally, you can load demo data and extract demo media files:

$ python src/ loaddata demo
$ cd media
$ tar -xzf demo.tgz

You can now run your installation and point your browser to the address given by this command:

$ python src/ runserver

If you are making local, machine specific, changes, add them to src/codelinker/conf/ You can base this file on the example file included in the same directory.

Enable SASS/Compass:

$ compass watch

For more information on SASS and Compass, see:

Get all Javascript libraries:

$ bower install

For more information on Node.js, see:

Staging and production

Configure your webserver and/or WSGI handler. See:

Note that your wsgi script in ``src/codelinker/ already points to your staging|production file. This happens when bootstrapping your environment.

Update installation

When updating an existing installation:

  1. Activate the virtual environment:

    $ cd codelinker
    $ source env/bin/activate
  2. Update the code and libraries:

    $ git pull
    $ pip install -r requirements/<production|staging|test|development>.txt
  3. Update the statics and database:

    $ python src/ collectstatic --link
    $ python src/ migrate

Custom management commands

Management commands are often run in a cronjob with stdout redirected to a log file.

Make sure to use the 'maven' management command, so use:

$ python src/ maven my_custom_management_command >> log/my_command.log 2>&1

This ensures that uncaught exceptions end up in Sentry instead of being overlooked in the log files