Skip to content

Andrew-oduola/django-referral

Repository files navigation

Django Referral

PyPI version
License: MIT
Django

A reusable Django app for implementing a referral system.
It allows users to generate unique referral links and track sign-ups using those links.


✨ Features

  • 🔗 Generate unique referral codes for each user
  • 👥 Track referrals during user sign-up
  • 🎁 Optionally reward users for successful referrals
  • 🍪 Cookie & middleware support for referral tracking
  • ⚡ Simple integration into existing Django projects

📦 Installation

1. Install the package

pip install django-referral2

2. Add to INSTALLED_APPS

In settings.py:

INSTALLED_APPS = [
    ...
    'referral',  # Add this line
]

3. Run migrations

python manage.py migrate referral

4. (Optional) Enable Middleware

If you want cookie-based referral tracking:

MIDDLEWARE = [
    ...
    'referral.middleware.ReferralMiddleware',
]

🚀 Usage

Generate a referral link

If a user has referral_code="ABC123", their referral link is:

https://yourdomain.com/signup?ref=ABC123

Track sign-ups

When a new user signs up with a referral link:

  • The app detects the referral code
  • Links the new user to the referrer
  • Saves the relationship in the database

🛠 Development Setup

Clone the repo and install dependencies:

git clone https://github.com/yourusername/django-referral-app.git
cd django-referral-app
pip install -r requirements.txt

📄 License

This project is licensed under the MIT License.


For a complete implementation example, check the documentation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages