Django school project
CSS JavaScript Python HTML Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Bagtrekkin Build Status Coverage Status

Bagtrekkin is a full-stack application involving both hardware and software.

This project takes place in a Lean Startup course at the University Federal of Pernambuco.

Install Bagtrekkin Django Application

The application uses Django 1.8 as main framework, PyJade as template rendering tool, Tastypie as API resource provider, UiKit as front-end style and PostgreSQL as database server.

The whole server-side application is currently hosted on Heroku. It uses web Dynos to run Procfile in order to start Gunicorn server.


By following those steps, you'll install the application development environment

  1. Clone Git repository:
$ git clone
  1. Create a virtualenv to host the application: You may need sudo to install virtualenv globally
# install virtualenv tool manager via pip
$ [sudo] pip install virtualenv
# create a new virtualenv folder called venv
$ virtualenv venv
# activate your virtualenv!
$ source venv/bin/activate
  1. Install application dependencies via pip: /!\ Be sure to have your virtualenv activated /!\ This is stipulated by (venv) in front of your terminal prompt.
(venv) $ pip install -r requirements.txt
(venv) $ pip install -r requirements-dev.txt

Currently both Tastypie and PyJade are installed from master development branch. When both package will be released in pip. Requirements must be edited.

Read more about Tastypie and PyJade support on Django 1.8.

  1. Install postgres database server On Debian based distributions, install from package manager:
$ apt-get install postgresql-9.4

On Mac OS X, install from Homebrew, MacPorts or use

$ brew install postgresql

Initiate a fresh database granted for current user:

$ initdb -D /usr/local/var/postgres

Launch postgresql:

$ pg_ctl -D /usr/local/var/postgres start

Create a new user named bagtrekkin with a password prompted:

$ createuser -W bagtrekkin

Create a dedicated database for bagtrakkin user:

$ createdb -O bagtrekkin -E UTF8 bagtrekkin

We can now try a connection to be sure all is properly setup:

$ psql -U bagtrekkin bagtrekkin
  1. Setup your local environment variables
  • Create a .env file in the same folder as
cat >> .env <<EOF
  • Replace <your_secret_key> with one generated, for instance, using MiniWebTool.

  • Replace <your_db_password> with the password you setup for postgres bagtrekkin user.

  1. Run Migrations to create and feed your database:
(venv) $ python migrate
  1. Test if everything runs well:
(venv) $ python runserver

You are now fully operational to join the developer team :)

/!\ Please read carefully How to Contribute /!\


In order to get closer to production environment, you can run python server the same way as Heroku actually do: using foreman.

Simply install globally Ruby foreman gem:

$ gem install -g foreman

And run server:

$ foreman start

Getting Started

Create your Employee Account (i.e. User)

The first thing you need to do is create a new user using Sign Up form. It is also an Employee. Once your account is created, you basically want to be a superuser in order to access django admin interface.

Enter in python shell

(venv) $ python shell

Import the corresponding module

>>> from django.contrib.auth.models import User

Get your user instance from the models

>>> foo = User.objects.get(username = '<your_username>')

Set your is_staff property to True

>>> foo.is_staff = True

Set your is_superuser property to True

>>> foo.is_superuser = True

Save your changes


Verification : load again your user instance from the models

>>> foo = User.objects.get(username = '<your_username')

Check that your changes are applied (next instruction should return True)

>>> foo.is_superuser

Doing the same on heroku

You will have to do the same to be superuser on heroku. Repeat the procedure above.

You can know update your local environment variables by adding:

cat >> .env <<EOF
  • Replace <your_api_key> with the one generated by the application when you'll create your account.

  • Replace <your_username> with the one used when you'll create your account.

This configuration is used by micro-client.

Understand application structure

  • arduino folder contains hardware code currently not being used by application server-side (i.e. Hosted on Heroku)

  • bagtrekkin folder contains the server-side application.

    • migrations folder contains all migrations run using migrate management command. If you want to create new migrations, please read carefully How to write Migrations.

    • static folder contains all static resources (i.e. js, css, fonts and img files used by the application).

    • templates folder contains all templates written in Jade and live time compiled using PyJade.

  • documentation folder contains documentation about the project

Git Documentation

  1. Getting Started
  2. Git Basics
  3. Git Branches
  4. Git on the server
  5. Distributed Git