Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Installation

Patrick Michaud edited this page May 10, 2017 · 6 revisions

These directions will get you started with the Django development server.

Prerequisites

A Python installation 2.7
pip
git

Step-by-step

If you don't have it already, install virtualenv:

$ pip install virtualenv

Checkout the master of the sqlshare-rest application:

$ git clone https://github.com/uw-it-aca/sqlshare-rest.git

Turn sqlshare-rest into a virtualenv:

$ virtualenv  sqlshare-rest   

Activate your virtualenv:

$ cd sqlshare-rest
$ source bin/activate

Install required Python packages with pip:

$ pip install -r requirements.txt

SQLShare supports multiple database backends. SQLite is used in development, and Postgresql is the primary production target. To install Postgresql requirements, run:

$ pip install -r requirements/pg.txt 

Create a django project in the sqlshare-rest dir:

$ django-admin.py startproject project .

That '.' at the end is important!

Modify at least the following settings in project/settings.py:

Add to INSTALLED_APPS:

'compressor',
'sqlshare_rest',
'oauth2_provider',
'authz_group',
'userservice',
'supporttools',
'templatetag_handlebars',

Add the following to be able to use the admin tools:

USERSERVICE_ADMIN_GROUP = 'sqlshare_support'
AUTHZ_GROUP_BACKEND = 'authz_group.authz_implementation.settings.Settings'
AUTHZ_GROUP_MEMBERS = { "sqlshare_support": [ "< Your Login Name >", ] }

Compressor requires a path it can write files to. For a development server, you can do:

STATIC_ROOT = 'static/'

For production, there are a number of considerations in the compressor documentation.

The 3rd party library that supports Google logins requires settings, even if you aren't using Google logins. You can add this to your settings.py file to get around it:

GOOGLE_OAUTH2_CLIENT_ID = ''
GOOGLE_OAUTH2_CLIENT_SECRET = ''

If you are at the point where you want to connect to a database instead of using SQLite, edit the DATABASES section.

We use pubcookie or shibboleth, so we configure Django to use REMOTE_USER to identify our users.

Your project/urls.py file will need to look something like this:

from django.conf.urls import include, url
    
from django.contrib.auth import views as auth_views
urlpatterns = [
    url(r'^', include('sqlshare_rest.urls')),
]

If you aren't using REMOTE_USER, you can add this line to use Django user authentication:

url(r'^accounts/login/$', auth_views.login),

Create the databases:

$ python manage.py migrate

You should now be able to run your development server:

$ python manage.py runserver 0.0.0.0:<your port>

If you go to http://<your development host>:<your port>/o/applications/ you should be able to create an OAuth application. You should be able to install the SQLShare Command Line Tools to test your installation.

Next up - installing the web front-end

Clone this wiki locally