Managers

class django_tinyuser.managers.FriendshipManager(*args, **kwargs)[source]

Bases: Manager

Custom manager for the Friendship model.

Provides methods to manage friendships between users, such as creating, accepting, rejecting, and blocking friendships.

property accepted_friendships

Return a queryset of all accepted friendships.

Returns:

A queryset of accepted friendships.

Return type:

QuerySet

property all_friendships

Return a queryset of all friendships for a given user.

Returns:

A queryset of all friendships.

Return type:

QuerySet

property blocked_by_user

Return a list of all users who have blocked the given user.

Returns:

A list of users who have blocked the given user.

Return type:

list

property blocked_friendships

Return a queryset of all blocked friendships.

Returns:

A queryset of blocked friendships.

Return type:

QuerySet

property blocked_from_users

Return a list of all users that the given user has blocked.

Returns:

A list of users that the given user has blocked.

Return type:

list

create_friendship(from_user, to_user)[source]

Create a new friendship request from one user to another.

Parameters:
  • from_user (TinyUser) – The user who is sending the friendship request.

  • to_user (TinyUser) – The user who is receiving the friendship request.

Returns:

The created Friendship instance.

Return type:

Friendship

property friend_requests

Return a queryset of all incoming friendship requests for a given user.

Returns:

A queryset of incoming friendship requests.

Return type:

list

property friends

Return a list of all friends for a given user.

Returns:

A list of friends.

Return type:

list

property pending_friendships

Return a queryset of all pending friendship requests.

Returns:

A queryset of pending friendships.

Return type:

QuerySet

property rejected_friendships

Return a queryset of all rejected friendships.

Returns:

A queryset of rejected friendships.

Return type:

QuerySet

class django_tinyuser.managers.TinyUserManager(*args, **kwargs)[source]

Bases: BaseUserManager

Custom user manager for TinyUser model.

Provides methods to create regular users and superusers.

create_superuser(email, username, password=None, **extra_fields)[source]

Create and save a superuser with the given email, username, and password.

Parameters:
  • email (str) – The email address of the superuser.

  • username (str) – The username of the superuser.

  • password (str, optional) – The password for the superuser, defaults to None

Raises:
  • ValueError – If is_staff is not True.

  • ValueError – If is_superuser is not True.

Returns:

The created superuser instance.

Return type:

TinyUser

create_user(email, username, password=None, **extra_fields)[source]

Create and save a regular user with the given email, username, and password.

Parameters:
  • email (str) – The email address of the user.

  • username (str) – The username of the user.

  • password (str, optional) – The password for the user, defaults to None

Raises:
  • ValueError – If the email is not provided.

  • ValueError – If the username is not provided.

Returns:

The created user instance.

Return type:

TinyUser