django-rest-friendship
Overview
DRF endpoints for django-friendship
Requirements
Python (3.8, 3.9, 3.10)
Django (3.2, 4.0)
Django REST Framework (3.13.1)
Installation
Install using pip…
pip install django-rest-friendship
Add rest_friendship to your INSTALLED_APPS
INSTALLED_APPS = (
...
'friendship', # Django friendship
'rest_framework', # Django REST Framework
'rest_friendship', # Django REST Friendship
'rest_framework.authtoken',
...
)
Also add settings for REST_FRIENDSHIP to your project settings.py
REST_FRIENDSHIP = {
'PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'USER_SERIALIZER': 'rest_friendship.serializers.FriendSerializer',
},
And don’t forget to add the following to your project urls.py
urlpatterns = [
...
path('', include('rest_friendship.urls')),
...
]
Examples
Get Friends List
curl -LX GET http://127.0.0.1:8000/friends/ -H 'Authorization: Token 16bd63ca6655a5fe8d25d7c8bb1b42605c77088b'
[{"id":1,"username":"testuser","email":"testuser@piboy.ca"}]
Add/Remove Friends
curl -X POST http://127.0.0.1:8000/friends/add_friend/ -H 'Authorization: Token 16bd63ca6655a5fe8d25d7c8bb1b42605c77088b' --data 'to_user=testuser&message=Hello+friend'
{"id":4,"from_user":"scott@gmail.com","to_user":"testuser@piboy.ca","message":"Hello friend","created":"2022-01-22T04:21:43.593950Z","rejected":null,"viewed":null}
curl -X POST http://127.0.0.1:8000/friends/remove_friend/ -H 'Authorization: Token 16bd63ca6655a5fe8d25d7c8bb1b42605c77088b' --data 'to_user=testuser'
[{"message": "Friend deleted"}]
Accept a Request with request ID
curl -X POST http://127.0.0.1:8000/friends/accept_request/ -H 'Authorization: Token 16bd63ca6655a5fe8d25d7c8bb1b42605c77088b' --data 'id=1'
{"message": "Request accepted, user added to friends."}
Testing
Install testing requirements and run with pytest:
pip install django-rest-friendship[test]
pytest
You can also use the excellent tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:
tox -s
Documentation
To build the documentation, you’ll need to install mkdocs.
pip install django-rest-friendship[docs]
To preview the documentation:
$ mkdocs serve
Running at: http://127.0.0.1:8000
To build the documentation:
mkdocs build
Metadata
Release files for django-rest-friendship 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-rest-friendship-0.2.1.tar.gz | 9.4 kB | Without provenance | Details for django-rest-friendship-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_rest_friendship-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for django_rest_friendship-0.2.1-py2.py3-none-any.whl |
Total release size: 19.2 kB
Release files / django-rest-friendship-0.2.1.tar.gz
| Download URL | django-rest-friendship-0.2.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05a9663156c170485b6459dd18bb823bbc0ff258121af38f980526a280d91128
|
|
BLAKE2b-256 checksum How to use checksums |
5e4bd903eb1372d7c92c4a1a2d68cfbac7f2960bad0c98886cd914da93ecbf2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / django_rest_friendship-0.2.1-py2.py3-none-any.whl
| Download URL | django_rest_friendship-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
dfd5321debf07b76c7babe57bfd47e099a60f2e9595a61e89568ee392015907d
|
|
BLAKE2b-256 checksum How to use checksums |
07b24ed849c4e5d49ff90567a4ea3bdb5579eaaa7ae063e54ddd54af9e102179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for django-rest-friendship 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.