Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

Blaggregator is a Django app with a Bootstrap frontend, that is deployed on Heroku and uses their Postgres and Scheduler add-ons.

This document aims to help you setup a development environment and to help you get started with the code.


Docker Setup

Requires Docker and Docker-compose to simplify setup of development environment. See the traditional setup section if you don't wish to use docker.

In web-variables.env fill out your credentials. See Credentials for instructions on generating.

docker-compose up
# Runs migrations and the app using runserver
# You can ssh into box to run other commands

Using Docker for the DB

It is possible to use Docker just for the DB and use the traditional setup for setting up your Python development environment.

docker-compose -f up --build

This will start a Postgres server that the server running on your local host machine can connect to, with no additional changes to the configuration.

Traditional Setup

  • Set up your virtual environment

  • Install dependencies:

$ pip install -r requirements.txt
  • Install Postgres (it's easy on OSX with and pip install psycopg2. Open the app to start your database server running locally.

    It is possible to use Docker for running the DB, if you prefer. See section Using Docker for the DB above.

    • Open a Postgres shell:

      $ psql
    • Create your database:

      CREATE DATABASE blaggregator_dev;

      The semicolon is critical. IMPORTANT: when you are creating your admin account on the db, don't use the same email address as your Recurse Center account or you won't be able to create a user account for yourself. Do or something.

    • Create the user for Django to use. As the postgres user, you can run the following:

    createuser --interactive --pwprompt
    Set username and password to `sasha`.  Let the new user create and delete databases.
  • Alternatively, you could use Sqlite instead of Postgres to get off the blocks, quickly. Change the value of 'ENGINE' in the DATABASES['default'] dictionary to 'django.db.backends.sqlite3'.

  • Set up initial tables:

$ python migrate
  • Bring the tables up to date with the latest South migrations:
$ python migrate

If you get this error:

OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

then your server isn't running. Go fiddle with

  • Turn on debugging in your environment so you can get useful error messages:
$ export DJANGO_DEBUG=True
  • Blaggregator uses oauth2 to log in users against and tokens to update user details. Store SOCIAL_AUTH_HS_KEY, SOCIAL_AUTH_HS_SECRET, and HS_PERSONAL_TOKEN in your environment. See Credentials for instructions on generating these.

  • Then run a local server:

$ python runserver

You can administer your app through the handy-dandy admin interface. To see this page, you'll need to give your user account superuser privileges:

  1. go to http://localhost:8000/ and auth in through HS's oauth
  2. $ python shell to open Django's shell and use its ORM
  3. >>> from django.contrib.auth.models import User import the User model (should you need the other models defined in, import from home.models. User uses Django's built-in User model)
  4. >>> u = User.objects.get(first_name="Sasha") or whatever your first name is. Grab your user object from the db.
  5. >>> u.is_superuser = True make your account a superuser so you can access the admin
  6. >>> Save these changes to the db.
  7. You should now be able to access localhost:8000/admin while logged in!



Go to your settings on, make a new app. Name it something like "blaggregator-local" and the url should be http://localhost:8000/complete/hackerschool/ (WITH trailing slash). There you can get SOCIAL_AUTH_HS_KEY and SOCIAL_AUTH_HS_SECRET.

Also create a personal access token and give it a name. This will generate the token to use for HS_PERSONAL_TOKEN.

Code overview

Key files:

  • home/ the heart of the app. all of the views ("controllers" if you're coming from Ruby)
  • blaggregator/ app settings
  • home/management/commands/ background crawler script
  • home/ feed parser
  • home/templates/home: all templates live here