Before you start working on the project, be sure to read this README and the linked docs.
How to Setup your Dev Environment with Docker
Requirements: Docker (Docker Desktop for macOS and Windows or Docker Compose for Linux), Python 3 with the invoke package installed globally, and git.
We recommend that you install Invoke using pipx, but any Python package manager should work (pip, poetry, etc).
Check your environment
docker run hello-world.
invoke --versionshould return 0.22.1 or higher.
Run the following terminal commands to get started:
git clone https://github.com/mozilla/foundation.mozilla.org.git
This task creates a
.env that is in charge of managing your environment variables while running Docker. The installation will take a few minutes: you need to download images from the Docker Hub, install JS and Python dependencies, create fake data, migrate your database, etc.
When it's done, run
docker-compose up, wait until the static files to be built, and go to
0.0.0.0:8000. You should have a local working version of the foundation site with fake data. When you want to stop, do
^C to shut down your containers.
To log into the admin site, a superuser will have been created with username
admin with password
To catch up on new dependencies, migrations, etc. after initial setup, you can use the
inv catch-up command. To get a full new environment with a new database, run
inv new-env again.
inv -l to get a list of all the available invoke commands.
More information on how to work with Docker and how to manage Python dependencies are available in the local development part of the documentation.
To ensure a consistent code style and quality, we use linters and formatters.
To check the code base for quality and style issues run
This will run all configured linters.
You can run the linters individually with, e.g.
Check available commands with
inv lint shows linting errors you can try running
inv format to fix style issues.
inv format should automatically fix most formatting issues.
There might be some linting issues that can not be fixed automatically.
When relevant, we encourage you to write tests.
You can run the tests using
This will the full test suite.
To run only a subset or a specific Python test, you can use following command:
inv manage "test <dotted-path-to-your-test>"
See also the Django docs on running tests.
Integration testing is done using Playwright, with the integration tests found in
You can run these tests locally by running a one-time
npm install and
npm run playwright:install after which you should be able to run
npm run playwright to run the visual tests, with
docker-compose up running in a secondary terminal.
In order to run the same tests as will run during CI testing, make sure that
RANDOM_SEED=530910203 is set in your
.env file, and that your local database is a new db based on that seed (
Note that this is still a work in progress.
Visual regression tests
We also use Playwright in combination with Browserstack's Percy to perform visual regression testing for PRs, using
./tests/visual.spec.js as screenshot baseline.
Visual regression tests are run after a pull request review has been approved.
Accessibility tests are currently unavailable but will use axe-playwright when the switchover from Cypress to Playwright is complete.
The fake data generator can generate a site structure for the Mozilla Festival that can be served under it's own domain, or in the case of review apps on Heroku, where we're limited to a single domain, as a sub-directory of the main foundation site, at
In order to access the Mozilla Festival site locally on a different domain than the main Foundation site, you'll need to edit your hosts file (
/etc/hosts on *nix systems,
C:\Windows\System32\Drivers\etc\hosts on Windows) to allow you to access the site at
mozfest.localhost:8000. To enable this, add the following line to your hosts file:
Ticket purchases are implemented using a third-party integration with Tito.
Tito Event snippet can be created for each event for which registration is needed. A
TitoWidget Streamfield block can be used to place a button on a page to open the Tito widget, linked to a specific
Tito Event needs a security token and newsletter question ID which can be found in the Customize -> Webhooks section of the Tito admin dashboard for the event.
A webhook (Django view) receives requests from Tito when a ticket is completed in order to sign users up for the Mozilla newsletter.
As this is REST API and CMS built on top of Django, there are some "gotcha!"s to keep in mind due to the high level of magic in the Django code base (where things will happen automatically without the code explicitly telling you).
DEBUG flag does all sorts of magical things, to the point where testing with debugging turned on effectively runs a completely different setup compared to testing with debugging turned off. When debugging is on, the following things happen:
- Django bypasses the
ALLOWED_HOSTrestrictions, which again can lead to
400 Bad Requesterrors in
- Rather than HTTP error pages, Django will generate stack traces pages that expose pretty much all environment variables except any that match certain substrings such as
PASS, etc. for obvious security reasons.
- ...there are probably more gotchas just for
DEBUGso if you find any please add them to this list.
Translations of UI strings (from the Django and React apps) are stored in the fomo-l10n repository. Translations are happening in Pontoon, in multiple projects: Foundation website, *Privacy Not Included and Mozilla Festival.
The latest source strings are regularly exposed to Pontoon by a Localization PM using the following process:
- Clone the
- Set the
LOCAL_PATH_TO_L10N_REPOvariable in your
.envfile. Use the absolute path to your copy of the
fomo-l10nrepository and include the trailing slash. E.g.
Exposing latest source strings:
- Make sure your local repositories of
foundation.mozilla.orgare matching the latest revision from main.
inv docker-makemessagesfrom your
- Files should have been updated in your
fomo-l10nrepository. You can now create a pull-request.
Getting the latest translations for local dev
Latest translations are uploaded to S3. To get them, run:
curl -o translations.tar https://foundation-site-translations.s3.amazonaws.com/translations.tar
tar -C network-api -xvf translations.tar
You don't need to run
compilemessages and it works for both pipenv or docker workflows.
translations_github_commit_[...] file from the archive is only used for debug purposes on Heroku. It can be safely deleted if needed.
We love contributors, but the team maintaining this project is small and not structured to significantly support new and inexperienced contributors. If there's an unassigned issue that catches your eye, feel free to open a PR for it, but keep in mind our support will be limited. We usually don't have the capacity to walk you through the process of spinning up the project, opening a PR or describing what the solution to the issue could be.