1. Marko Mrdjenovic
  2. django-registration-plus

Source

django-registration-plus / registration / management / commands / createinvitations.py

"""
A management command which gives an invitation to all registered users.

Calls ``RegistrationInvitation.objects.create_invitation()`` for all the users.

"""

from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User

from registration.models import RegistrationInvitation


class Command(NoArgsCommand):
    help = "Give every registered user an invitation"
    
    def handle_noargs(self, **options):
        for u in User.objects.filter(is_active=True):
            RegistrationInvitation.objects.create_invitation(u)