Home > other >  How can I get a list of pending invitations for a user using django-invitations?
How can I get a list of pending invitations for a user using django-invitations?

Time:08-22

I can see in the source code for django-invitations that there is a manager with an all_valid method but I'm having trouble connecting the dots back to request.user.

I'm also using django-allauth.

CodePudding user response:

You can use this if you want to get invitations sent for the current user:

Invitation.objects.all_valid().filter(
    email__iexact=request.user.email, accepted=False,
)

CodePudding user response:

To get a list of invitations sent by the user, that are still pending, use:

from invitations.models import Invitation
Invitation.objects.all_valid().filter(inviter=request.user, accepted=False)
  • Related