Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions apps/feature-flags/django/django3-saas/.env.example

This file was deleted.

29 changes: 0 additions & 29 deletions apps/feature-flags/django/django3-saas/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "flagKeys": ["wizard-example-backend-flag"] }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "sourceApp": "basic-integration/django/django3-saas" }
142 changes: 16 additions & 126 deletions apps/feature-flags/django/django3-saas/README.md
Original file line number Diff line number Diff line change
@@ -1,131 +1,21 @@
# Django SaaS example app
# Feature flags: Django 3 SaaS

A Django 3.0+ SaaS application for testing PostHog wizard integration. This app provides subscription billing, user authentication, and project management features.
Runs the `wizard feature-flags` e2e against the source tree of
[`basic-integration/django/django3-saas`](../../../basic-integration/django/django3-saas),
named by `sourceApp` in `.wizard-ci/source.json`. PostHog is not installed there.

## Running the app
There is no code here on purpose: a copy of the app would drift from the one it
was copied from.

### Prerequisites
Expected wizard outcome, graded by `services/wizard-ci/feature-flag-checks.ts`
against the keys in `.wizard-ci/feature-flags.json`:

- Python 3.10+
- SQLite (included with Python, used by default)
- Stripe account (optional, app runs in demo mode without it)
- the backend example flag exists in the project, inactive at 0% rollout; the
templates hold no scripts, so there is no frontend side and no frontend flag
- the key appears in exactly one changed file, its constants module, and
another changed file imports that module
- no changed file holds a `wizard-example-*` key outside that list
- `posthog-feature-flags-report.md` exists

### Installation

1. Create and activate a virtual environment:

```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

1. Install dependencies:

```bash
pip install -r requirements.txt
```

1. Set up environment variables (create a `.env` file):

```bash
SECRET_KEY=your-secret-key
# DATABASE_URL=postgresql://... # Optional, defaults to SQLite
STRIPE_PUBLIC_KEY=pk_test_... # Optional, enables Stripe
STRIPE_SECRET_KEY=sk_test_... # Optional, enables Stripe
STRIPE_WEBHOOK_SECRET=whsec_... # Optional, for webhooks
```

> **Note:** By default, the app uses SQLite (`db.sqlite3`) and runs in demo mode without Stripe. No additional setup is required for local development.

1. Initialize the database:

```bash
python manage.py migrate
python manage.py seed_plans # Optional: seed pricing plans
```

1. Run the development server:

```bash
python manage.py runserver
```

The app will be available at `http://127.0.0.1:8000`.

---

## Application structure

```
├── manage.py # Django management script
├── requirements.txt # Python dependencies
├── accounts/ # User authentication & profiles
│ ├── models.py # Custom User model
│ ├── views.py # Login, register, password reset
│ └── forms.py # Auth forms
├── billing/ # Subscription & payment handling
│ ├── models.py # Plan, Subscription models
│ ├── views.py # Stripe checkout, webhooks, billing portal
│ ├── admin.py # Django admin customization
│ └── management/ # seed_plans command
├── config/ # Django settings
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── dashboard/ # Main app functionality
│ ├── models.py # Project, ActivityLog models
│ ├── views.py # Dashboard, project CRUD
│ └── forms.py
├── marketing/ # Public pages
│ └── views.py # Home, features pages
├── static/ # CSS, JS, images
└── templates/ # HTML templates
```

## Features

### Authentication

- User registration with email
- Login/logout with session management
- Password reset via email
- User profiles and settings

### Billing & subscriptions

- Pricing page with plan tiers
- Stripe Checkout integration
- Subscription management (upgrade/downgrade/cancel)
- Stripe webhook handling
- Demo mode when Stripe is not configured

### Dashboard

- Project CRUD (create, read, update, delete)
- Activity logging
- Usage metrics display
- Subscription status

### Admin panel

- Django admin at `/admin/`
- Plan management with subscriber counts
- Subscription management with status badges

## Database models

| Model | Description |
|-------|-------------|
| `User` | Custom user model with authentication and Stripe customer ID |
| `Plan` | Subscription plans with pricing and Stripe price IDs |
| `Subscription` | User subscriptions with status tracking |
| `Project` | User projects with activity logging |
| `ActivityLog` | Audit trail for user actions |

## Key dependencies

- **Django** - Web framework
- **Stripe** - Payment processing
- **Whitenoise** - Static file serving
- **dj-database-url** - Database configuration from URL
- **python-dotenv** - Environment variable management
The flag checks cannot prove this run created the flag: CI never deletes the
shared key, because parallel legs share it.
Empty file.
11 changes: 0 additions & 11 deletions apps/feature-flags/django/django3-saas/accounts/admin.py

This file was deleted.

22 changes: 0 additions & 22 deletions apps/feature-flags/django/django3-saas/accounts/forms.py

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
31 changes: 0 additions & 31 deletions apps/feature-flags/django/django3-saas/accounts/models.py

This file was deleted.

17 changes: 0 additions & 17 deletions apps/feature-flags/django/django3-saas/accounts/urls.py

This file was deleted.

Loading
Loading