Developer Setup with virtualenv¶
The following describes how to set up an instance of the site on your computer for development.
Installation with virtualenv is not recommended. If possible, please use Developer Setup with Docker, which is simpler and makes it easier for us to reproduce potential issues.
This guide assumes you have already installed and set up the following:
These docs assume a Unix-like operating system, although the site should, in theory, run on Windows as well. All the example commands given below are intended to be run in a terminal. If you’re on Ubuntu 16.04, you can install all the prerequisites using the following command:
sudo apt install git python-pip nodejs-legacy npm postgresql postgresql-server-dev-9.5 postgresql-contrib-9.5 libxml2-dev libxslt1-dev python-dev libmemcached-dev virtualenv
If you’re on Ubuntu 17.04, you can install all the prerequisites using the following command:
sudo apt install git python-pip nodejs-legacy npm postgresql postgresql-server-dev-9.6 postgresql-contrib-9.6 libxml2-dev libxslt1-dev python-dev libmemcached-dev virtualenv
Clone this repository or your fork:
git clone https://github.com/mozilla/pontoon.git cd pontoon
Create a virtualenv for Pontoon and activate it:
virtualenv venv source ./venv/bin/activate
Whenever you want to work on Pontoon in a new terminal you’ll have to re-activate the virtualenv. Read the virtualenv documentation to learn more about how virtualenv works.
Install the dependencies using the latest version of pip:
pip install --require-hashes -r requirements/dev.txt pip install --require-hashes -r requirements/test.txt
Create your database, using the following set of commands:
sudo -u postgres psql CREATE USER pontoon WITH PASSWORD 'asdf' SUPERUSER; CREATE DATABASE pontoon; GRANT ALL PRIVILEGES ON DATABASE pontoon to pontoon; \q
.envfile at the root of the repository to configure the settings for your development instance. It should look something like this:
SECRET_KEY=insert_random_key DJANGO_DEV=True DJANGO_DEBUG=True DATABASE_URL=postgres://pontoon:asdf@localhost/pontoon SESSION_COOKIE_SECURE=False SITE_URL=http://localhost:8000 FXA_CLIENT_ID=2651b9211a44b7b2 FXA_SECRET_KEY=a3cafccbafe39db54f2723f8a6f804c337e362950f197b5b33050d784129d570 FXA_OAUTH_ENDPOINT=https://oauth-stable.dev.lcip.org/v1 FXA_PROFILE_ENDPOINT=https://stable.dev.lcip.org/profile/v1
Make sure to make the following modifications to the template above:
SECRET_KEYshould be set to some random key you come up with, as it is used to secure the authentication data for your local instance.
DATABASE_URLshould contain the connection data for connecting to your Postgres database. It takes the form
SITE_URLshould be set to the URL you will use to connect to your local development site. Some people prefer to use
localhost. However, should you decide to change the
SITE_URL, you also need to request the new
FXA_SECRET_KEY, and our in-context demo site
http://localhost:8000/in-context/will require change of base url.
Initialize your database by running the migrations:
python manage.py migrate
Create a new superuser account:
python manage.py createsuperuser
Make sure that the email address you use for the superuser account matches the email that you will log in with via Firefox Accounts.
Pull the latest strings from version control for the Pontoon Intro project (which is automatically created for you during the database migrations):
python manage.py sync_projects --projects=pontoon-intro --no-commit
After you’ve provided credentials to Firefox Accounts, you have to update them in database, because it’s required by django-allauth. You will have to call this command after every change in your FXA settings (e.g. client key):
python manage.py updatefxaprovider
Install the required Node libraries using
- Run webpack:
Once you’ve finished these steps, you should be able to start the site by running:
python manage.py runserver
The site should be available at http://localhost:8000.
The following extra settings can be added to your
- Set your Google Cloud Translation API key to use machine translation by Google.
- Set your Microsoft Translator API key to use machine translation by Microsoft.
- Set your Google Analytics key to use Google Analytics.
- Enable Sync button in project Admin.
- Set to True if you want to use the default Django login instead of Firefox Accounts. This will allow you to log in via accounts created using manage.py shell.