The matching application adds support for so-called “matchmaking” of mentors and mentees. This includes invitations to form matchmaking relationships as represented by the mentoring.models.Relationship model.


class matching.models.Invitation(*args, **kwargs)[source]

An invitation to form a mentoring relationship.

Invites are the mechanism where mentor/mentee relationships are created. The clean() method of this model is overridden to allow invites to be created by anyone but, in that case, they need to be the mentor or mentee of the invite. Users with the “add_invitation” permission can invite any two users to form a mentor/mentee relationship.

Each invitation records who the mentor and mentee are to be and the user who created the invite. (This is useful to determine which of the mentors and mentees should actually be notified.) The creation date is also stored to allow for some form of automatic expiry.

An “active” invite is one which is not expired and is still awaiting a response from the mentor or mentee. An invitation which is declined by either mentor or mentee should be marked as inactive even if the other party has not responded.

The deactivated_on date records when this invite became inactive either through being declined by one party, accepted by both or manually deactivated.

Should the invite result in a new relationship, this is recorded in the created_relationship field.

RESPONSES = (('A', 'Accept'), ('D', 'Decline'))

The possible responses to an invitation.


Extra validation for invitations.

Creating invitations when the creator is not the mentor or mentee requires that the creator have the “add_invitation” permission.


The User who created this invitation

created_on = None

The date this invitation was created


If this invite lead to a mentoring relationship, it is recorded here


Deactivate this invite without creating a relationship.

Does nothing if the invite is already deactivated.

deactivated_on = None

If inactive, when did this invite become so


Returns True iff both the mentee and mentor have accepted the invite.


Returns True iff the invite is active (i.e. the “deactivated_on” date is blank).


The proposed mentee for this relationship

mentee_response = None

The response from the mentee to the invite


The proposed mentor for this relationship

mentor_response = None

The response from the mentor to the invite

respond(user, accepted)[source]

Set the response of the specified user. If the user is neither the mentor or mentee then a PermissionDenied exception is raised.

class matching.models.InvitationManager[source]

Model manager for Invitation model.


Return a query set giving only the active invitations.

class matching.models.Preferences(*args, **kwargs)[source]

Records the mentorship opinions of a User.

matching.models.invitation_create_relationships(instance, **_)[source]

A pre-save hook for Invitation instances which creates a mentoring relationship if:

  • The invitation is accepted
  • The invitation is active
  • There is no current relationship


class matching.forms.InvitationResponseForm(data=None, files=None, auto_id=u'id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None)[source]

A form for responding to an invitation.

Validates that the user responding to the invitation is one of the mentor or the mentee and that the invitation is active.


invitation = # ... Retrieve Invitation instance
f = InvitationResponseForm(
    data={'user':, 'response': Invitation.ACCEPT},
response = None

The response. One of Invitation.ACCEPT or Invitation.DECLINE

user = None

The database primary key for the user responding to the invitation.