{"id":13502685,"url":"https://github.com/revsys/django-friendship","last_synced_at":"2025-05-15T05:06:54.660Z","repository":{"id":3001440,"uuid":"4019382","full_name":"revsys/django-friendship","owner":"revsys","description":"Django app to manage following and bi-directional friendships","archived":false,"fork":false,"pushed_at":"2024-08-16T20:53:32.000Z","size":388,"stargazers_count":763,"open_issues_count":8,"forks_count":181,"subscribers_count":34,"default_branch":"main","last_synced_at":"2025-05-15T00:22:48.266Z","etag":null,"topics":["django","friendship","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/revsys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-13T19:15:27.000Z","updated_at":"2025-05-12T11:46:28.000Z","dependencies_parsed_at":"2025-03-17T04:45:38.486Z","dependency_job_id":null,"html_url":"https://github.com/revsys/django-friendship","commit_stats":{"total_commits":305,"total_committers":50,"mean_commits":6.1,"dds":0.6622950819672131,"last_synced_commit":"efcfd5c4bad8f228163933886415fc29759d5abb"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-friendship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-friendship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-friendship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-friendship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revsys","download_url":"https://codeload.github.com/revsys/django-friendship/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254743,"owners_count":22039927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","friendship","python"],"created_at":"2024-07-31T22:02:22.321Z","updated_at":"2025-05-15T05:06:49.635Z","avatar_url":"https://github.com/revsys.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# django-friendship\n\n[![CI](https://github.com/revsys/django-friendship/actions/workflows/actions.yml/badge.svg)](https://github.com/revsys/django-friendship/actions/workflows/actions.yml)\n\nThis application enables you to create and manage follows, blocks and bi-directional friendships between users. It features:\n\n- Friendship request objects that can be accepted, rejected, canceled, or marked as viewed.\n- Hooks to easily list all friend requests sent or received by a given user, filtered by the status of the request.\n- A blocklist for each user of users they've blocked.\n- Tags to include information about friendships, blocks and follows in your templates.\n- Integration with `AUTH_USER_MODEL`.\n- Validation to prevent common mistakes.\n- Faster server response time through caching\n\n## Requirements\n\nDjango 5.0 and 5.1 + Python 3.11 and Python 3.12 support added **\u003ev1.9.6**\n\nPreviously: \n\n- **Django 3.2 since v1.9.1**\n- **Django 1.11+** since v1.7.0 (latest release supporting **Django 1.10** is v1.6.0)\n\n## Installation\n\n1. `pip install django-friendship`\n2. add `\"friendship\"` to `INSTALLED_APPS` and run `python manage.py migrate`.\n3. Use the friendship manager in your own views, or wire up the URLconf to include the builtin views:\n\n```python\nurlpatterns = [\n    ...\n    path('friendship/', include('friendship.urls'))\n    ...\n]\n```\n\nNote: If you are migrating from django-friendship `v1.6.x`, you'll need to rollback your migrations and fake\nmigration `0002`\n\n```shell\n$ ./manage.py migrate friendship 0001\n$ ./manage.py migrate friendship 0002 --fake\n```\n\nIf you're migrating from `v1.7.x`, you'll likely have to fake `0003` as well:\n\n```shell\n$ ./manage.py migrate friendship 0003 --fake\n```\n\n## Usage\n\n`django-friendship` provides a free API that gives you several ways to create and manage friendship requests or follows in your views. Add the following at the top of your `views.py`:\n\n```python\nfrom django.contrib.auth.models import User\nfrom friendship.models import Friend, Follow, Block\n```\n\n### Getting Data about Friendships\n\n- List all of a user's friends: `Friend.objects.friends(request.user)`\n- List all unread friendship requests: `Friend.objects.unread_requests(user=request.user)`\n- List all unrejected friendship requests: `Friend.objects.unrejected_requests(user=request.user)`\n- Count of all unrejected friendship requests: `Friend.objects.unrejected_request_count(user=request.user)`\n- List all rejected friendship requests: `Friend.objects.rejected_requests(user=request.user)`\n- Count of all rejected friendship requests: `Friend.objects.rejected_request_count(user=request.user)`\n- List of all sent friendship requests: `Friend.objects.sent_requests(user=request.user)`\n- Test if two users are friends: `Friend.objects.are_friends(request.user, other_user) == True`\n\n### Getting Data about Follows\n\n- List of a user's followers: `Follow.objects.followers(request.user)`\n- List of who a user is following: `Follow.objects.following(request.user)`\n\n### Getting Data about Blocks\n\n- List of a user's blockers: `Block.objects.blocked(request.user)`\n- List of who a user is blocking: `Block.objects.blocking(request.user)`\n- Test if a user is blocked: `Block.objects.is_blocked(request.user, other_user) == True`\n\n### Managing Friendships and Follows\n\n#### Create a friendship request:\n\n```python\nother_user = User.objects.get(pk=1)\nFriend.objects.add_friend(\n    request.user,                               # The sender\n    other_user,                                 # The recipient\n    message='Hi! I would like to add you')      # This message is optional\n```\n\n#### Let the user who received the request respond:\n\n```python\nfrom friendship.models import FriendshipRequest\n\nfriend_request = FriendshipRequest.objects.get(from_user=request.user, to_user=other_user)\nfriend_request.accept()\n# or friend_request.reject()\n```\n\n#### To remove the friendship relationship between `request.user` and `other_user`, do the following:\n\n```python\nFriend.objects.remove_friend(request.user, other_user)\n```\n\n#### Make request.user a follower of other_user:\n\n```python\nFollow.objects.add_follower(request.user, other_user)\n```\n\n\n#### Make request.user block other_user:\n\n```python\nBlock.objects.add_block(request.user, other_user)\n```\n\n#### Make request.user unblock other_user:\n\n```python\nBlock.objects.remove_block(request.user, other_user)\n```\n\n### Templates\n\nYou can use `django-friendship` tags in your templates. First enter:\n\n```django\n{% load friendshiptags %}\n```\n\nThen use any of the following:\n\n```django\n{% friends request.user %}\n{% followers request.user %}\n{% following request.user %}\n{% friend_requests request.user %}\n{% blockers request.user %}\n{% blocking request.user %}\n```\n\n### Signals\n\n`django-friendship` emits the following signals:\n\n- friendship_request_created\n- friendship_request_rejected\n- friendship_request_canceled\n- friendship_request_accepted\n- friendship_removed\n- follower_created\n- following_created\n- follower_removed\n- following_removed\n- block_created\n- block_removed\n\n### Settings\n\n`django-friendship` supports the following settings:\n\n```python\nFRIENDSHIP_CONTEXT_OBJECT_NAME = 'user'\nFRIENDSHIP_CONTEXT_OBJECT_LIST_NAME = 'users'\nFRIENDSHIP_MANAGER_FRIENDSHIP_REQUEST_SELECT_RELATED_STRATEGY = 'select_related'  # ('select_related', 'prefetch_related', 'none')\n```\n\n### Contributing\n\nDevelopment [takes place on GitHub](https://github.com/revsys/django-friendship). Bug reports, patches, and fixes are always welcome!\n\n# Need help?\n\n[REVSYS](http://www.revsys.com?utm_medium=github\u0026utm_source=django-test-plus) can help with your Python, Django, and infrastructure projects. If you have a question about this project, please open a GitHub issue. If you love us and want to keep track of our goings-on, here's where you can find us online:\n\n\u003ca href=\"https://revsys.com?utm_medium=github\u0026utm_source=django-friendship\"\u003e\u003cimg src=\"https://pbs.twimg.com/profile_images/915928618840285185/sUdRGIn1_400x400.jpg\" height=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/revsys\"\u003e\u003cimg src=\"https://cdn1.iconfinder.com/data/icons/new_twitter_icon/256/bird_twitter_new_simple.png\" height=\"43\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.facebook.com/revsysllc/\"\u003e\u003cimg src=\"https://cdn3.iconfinder.com/data/icons/picons-social/57/06-facebook-512.png\" height=\"50\" /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Fdjango-friendship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevsys%2Fdjango-friendship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Fdjango-friendship/lists"}