Pegasus’s Code Structure#
This is the overall structure of a new Pegasus project:
│ ├── subscriptions
│ ├── teams
│ ├── users
│ ├── utils
│ └── web
│ ├── apps
│ └── styles
The first three directories are Python modules while the remaining ones are not.
This is your Django project root directory.
It’s where your settings, root urlconf and
wsgi.py file will live.
This is where your project’s apps will live. It is pre-populated with Pegasus’s default apps for you to further customize to your needs.
The module starts with several apps, depending on your configuration. Here are some of the main ones:
contentis where the Wagtail CMS models are configured.
subscriptionsis for functionality related to Stripe subscriptions.
usersis where your user models and views are defined.
teamsis where team models and views are defined.
utilsis a set of functionality shared across the project.
webcontains utilities and components related to the generic views, layouts and templates.
This is where the Pegasus examples live.
In general, it is not expected that you’ll need to modify much in this module, though feel free to do so!
This is where you define your project’s Python requirements.
Requirements are managed using
For more information on using it see their documentation.
See front-end for more information on how to compile these files.
This folder contains your project’s static files, including the compiled output files
assets folder as well as images.
This folder contains your project’s Django templates.
There is one sub-folder for each application that has templates.
The majority of the project’s base template layouts are in the
The project will also include pre-commit as a dependency in the requirements file
as well as the
.pre-commit-config.yaml file in the root directory. pre-commit is a tool for managing pre-commit
hooks - which can be used to ensure your code matches the correct format when it’s committed.
After installing the project dependencies you can install the pre-commit hooks:
$ pre-commit install --install-hooks
pre-commit installed at .git/hooks/pre-commit
The default configuration that ships with Pegasus will run
black prior to every Git
commit. If there are fixes that are needed you will be notified in the shell output.
Manually running hooks
# run all hooks against currently staged files
# run all the hooks against all the files. This is a useful invocation if you are using pre-commit in CI.
pre-commit run --all-files
# only run the isort hook against all staged files
pre-commit run isort
Temporarily disable hooks See https://pre-commit.com/#temporarily-disabling-hooks
For more information on using and configuring pre-commit check out the pre-commit docs
The configuration for the tools can be found in the
See this cookbook for guidance on how to enable code formatting on an existing Pegasus project.