Basic Configuration

  1. Configure INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        ...
        'django_flex_user.apps.DjangoFlexUserConfig', # Add me
        'rest_framework', # Add me
        'rest_framework.authtoken', # Add me
        'drf_multiple_model', # Add me
        'social_django', # Add me
    ]
    
  2. Configure AUTHENTICATION_BACKENDS in settings.py:

    AUTHENTICATION_BACKENDS = [
        'django_flex_user.backends.FlexUserModelBackend',
    ]
    
  3. Configure AUTH_USER_MODEL in settings.py:

    AUTH_USER_MODEL = 'django_flex_user.FlexUser'
    

    Warning

    You cannot change the AUTH_USER_MODEL setting during the lifetime of a project (i.e. once you have made and migrated models that depend on it) without serious effort. It is intended to be set at the project start, and the model it refers to must be available in the first migration of the app that it lives in. See Substituting a custom User model for more details.

  4. Register a callback function for sending emails in settings.py:

    FLEX_USER_OTP_EMAIL_FUNCTION = ...
    

    Your callback function should have the following signature:

    email_otp(email_token, **kwargs)

    Send one-time password via email.

    Parameters
    • email_token (EmailToken) – The OTP token object.

    • kwargs (dict, optional) – The named arguments passed to send_password()

    Raises

    TransmissionError – If email fails to send.

    Returns

    None

    Return type

    None

  5. Register a callback function for sending SMS messages in settings.py:

    FLEX_USER_OTP_SMS_FUNCTION = ...
    

    Your callback function should have the following signature:

    sms_otp(phone_token, **kwargs)

    Send one-time password via SMS.

    Parameters
    • email_token (PhoneToken) – The OTP token object.

    • kwargs (dict, optional) – The named arguments passed to send_password()

    Raises

    TransmissionError – If SMS fails to send.

    Returns

    None

    Return type

    None

  6. Apply database migrations:

    $ python mange.py migrate
    

    Note

    On Windows, the command to execute Python is py.

  7. Create a superuser:

    $ python mange.py createsuperuser
    

    Note

    On Windows, the command to execute Python is py.