Cookbooks

Step-by-step guide to some different you might want to do with Pegasus.

Pegasus customers can request content be added to this page! Just get in touch via support.

Use the Django Admin UI

Pegasus ships with a simple script to promote any user to a superuser who can access the Django admin.

After going through the sign up flow, to convert your newly-created user into an admin, run the following command, being sure to replace the email address with the one you used to sign up:

python ./manage.py promote_user_to_superuser yourname@example.com

Now you should be able to access the django admin at http://localhost:8000/admin

Delete Pegasus Examples

The Pegasus examples are great for seeing a fully-working end-to-end feature, but in your app you probably don’t want them around long term. To remove the examples entirely, take the following steps:

Cleaning the back-end code

  1. In settings.py, remove 'pegasus.apps.examples.apps.PegasusExamplesConfig' from PEGASUS_APPS.
  2. In your root urls.py, remove the line containing include('pegasus.apps.examples.urls').
  3. In apps/web/templates/web/components/top_nav.html, remove the section linking to the Examples Gallery.
  4. Delete the entire pegasus/apps/examples directory.
  5. Delete the entire templates/pegasus/examples directory.

Cleaning the front-end code

  1. In assets/index.js remove the require('./javascript/pegasus/examples/object-lifecycle.js'); and './javascript/pegasus/pegasus.js' lines.
  2. In webpack.config.js, delete the 'object-lifecycle' and 'pegasus' entries from module.exports.
  3. Delete the assets/javascript/pegasus/ folder.
  4. Delete static/js/object-lifecycle-bundle.js and static/js/pegasus-bundle.js

Delete Teams Code

If you aren’t using teams there are a few things you can cleanup on the front end code.

  1. In assets/index.js remove the require('./javascript/pegasus/teams.js'); line.
  2. In webpack.config.js, delete the teams entry from module.exports.
  3. Delete assets/javascript/pegasus/teams.js.
  4. Delete static/js/teams-bundle.js

Delete Stripe Code

If you aren’t using Stripe you can remove the code and dependencies by doing the following steps.

Note that this requires starting from a fresh database, or manually manipulating your migrations.

  1. In settings.py remove djstripe from THIRD_PARTY_APPS
  2. In settings.py remove STRIPE_ and DJSTRIPE_ settings
  3. Delete pegasus/apps/components/stripe.py
  4. Delete pegasus/utils/subscriptions.py
  5. Delete pegasus/decorators.py
  6. In pegasus/apps/users/models.py, remove code referencing SubscriptionModelMixin (import and class inheritance)
  7. In pegasus/apps/users/models.py, remove customer and subscription fields on the model
  8. In pegasus/apps/teams/models.py, remove code referencing SubscriptionModelMixin (teams build only)
  9. In pegasus/apps/users/models.py, remove subscription field on the model (teams build only)
  10. Delete templates/stripe directory
  11. In assets/javascript/pegasus/Pegasus.js remove export { Payments } from './Payments'; line.
  12. Delete assets/javascript/pegasus/Payments.js.
  13. Delete your apps/users/migrations folder.
  14. Delete your apps/teams/migrations folder.
  15. Run ./manage.py makeimgrations users (teams build only)
  16. Run ./manage.py makeimgrations teams (teams build only)
  17. Run ./manage.py migrate
  18. In requirements/requirement.in and requirements/requirement.txt remove stripe and dj-stripe lines.
  19. Run pip-sync

Using the Payments example

To make the Payments example a part of your own application, see this page.