Skip to main content

Linked Data Platform interface for Django Rest Framework

Project description

DjangoLDP

A Django package that extends Django REST Framework to serve models following the W3C Linked Data Platform convention, with support for RDF serialization and ActivityPub federation.

Check the official documentation.


Settings

  • OIDC_ACCESS_CONTROL_ALLOW_HEADERS: overrides the access control headers allowed in the Access-Control-Allow-Headers CORS header of responses. Defaults to authorization, Content-Type, if-match, accept, DPoP
  • ANONYMOUS_USER_NAME a setting inherited from dependency Django-Guardian
  • DJANGOLDP_PERMISSIONS: overrides the list of all permissions on all resources
  • SERIALIZER_CACHE: toggles the use of a built-in cache in the serialization of containers/resources
  • MAX_RECORDS_SERIALIZER_CACHE: sets the maximum number of serializer cache records, at which point the cache will be cleared (reset). Defaults to 10,000
  • SEND_BACKLINKS: enables the searching and sending of Activities to distant resources linked by users to this server
  • MAX_ACTIVITY_RESCHEDULES, DEFAULT_BACKOFF_FACTOR, DEFAULT_ACTIVITY_DELAY, DEFAULT_REQUEST_TIMEOUT tweaks the behaviour of the ActivityQueueService
  • STORE_ACTIVITIES: sets whether to store activities sent and backlinks received, or to treat them as transient (value should be "VERBOSE", "ERROR" or None). Defaults to "ERROR"
  • MAX_RECORDS_ACTIVITY_CACHE: sets the maximum number of serializer cache records, at which point the cache will be cleared (reset). If set to 0 disables the cache. Defaults to 10,000
  • ENABLE_SWAGGER_DOCUMENTATION: enables the automatic OpenAPI-based API schema and documentation generation, made available at http://yourserver/docs/ is the flag is set to True. Default to False
  • DISABLE_LOCAL_OBJECT_FILTER: disabled the LocalObjectBackendFilter which is processing-time costly and only need activation in federated architecture, so we preferred to add a way to disable it as a workaround for in-progress performances improvements. Default to False

Synopsis

This module is an add-on for Django REST Framework that serves a django model respecting the Linked Data Platform convention.

It aims at enabling people with little development skills to serve their own data, to be used with a LDP application.

Check technical documentation

Contribute to DjangoLDP

Testing

Packaged with DjangoLDP is a tests module, containing unit tests

You can extend these tests and add your own test cases by following the examples in the code. You can then run your tests with: python -m unittest djangoldp.tests.runner

Check your datas integrity

Because of the way the DjangoLDP's federation work, you can reach some integrity issue within your datas.

You can check them with:

./manage.py check_integrity

You can ignore some servers:

./manage.py check_integrity --ignore "https://server/,https://another-server/"

Add you own commands to the check_integrity from your own package

Create a check_integrity.py file within your app folder containing:

def add_arguments(parser):
  parser.add_argument(
    "--my-own-argument",
    default=False,
    nargs="?",
    const=True,
    help="Some help text",
  )

def check_integrity(options):
  if(options["my_own_argument"]):
    print("You ran a check_integrity with --my-own-argument!")
  else:
    print("Run me with `./manage.py check_integrity --my-own-argument`")

You can see a sample on the check_integrity.py file of DjangoLDP.

What's New in v5.0.0

Major Changes

  • Django 5 LTS - Upgraded to Django 5.2 LTS
  • Turtle Serialization - Full RDF Turtle parser and renderer (guide)
  • ETag Support - Conditional requests with If-Match, If-None-Match, If-Modified-Since
  • Link Headers - W3C LDP-compliant pagination and type headers
  • OPTIONS Method - Full implementation with Allow, Accept-Post, Accept-Patch
  • Prefer Headers - RFC 7240 support (return=minimal, return=representation)

Quick Examples

# Request Turtle format
curl -H "Accept: text/turtle" http://localhost:8000/users/

# Conditional update (prevents conflicts)
curl -X PUT -H "If-Match: W/\"abc123\"" -d '{"name":"updated"}' http://localhost:8000/users/1/

# Minimal response (faster)
curl -X POST -H "Prefer: return=minimal" -d '{"name":"new"}' http://localhost:8000/users/

Documentation

Document Description
Turtle Serialization How to use RDF Turtle format
HTTP Headers Complete headers reference
v5.0.0 Changelog Full list of changes
LDP Compliance W3C specification compliance
Architecture Codebase architecture

License

Licence MIT

Project details


Release history Release notifications | RSS feed

This version

5.0.7

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangoldp-5.0.7.tar.gz (135.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djangoldp-5.0.7-py2.py3-none-any.whl (182.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file djangoldp-5.0.7.tar.gz.

File metadata

  • Download URL: djangoldp-5.0.7.tar.gz
  • Upload date:
  • Size: 135.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/8.7.1 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.15

File hashes

Hashes for djangoldp-5.0.7.tar.gz
Algorithm Hash digest
SHA256 5e3684deedfcd069c4ff7b3ca930d2e5dd6031a48d60079e90d46a3851a72696
MD5 6643e2f6fa52daa22459b85027d4fba1
BLAKE2b-256 4ea11081b81f438f463fb1530e2ecb9075443a603f1408eaa4d263233cf317b5

See more details on using hashes here.

File details

Details for the file djangoldp-5.0.7-py2.py3-none-any.whl.

File metadata

  • Download URL: djangoldp-5.0.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 182.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.32.5 requests-toolbelt/1.0.0 urllib3/2.6.3 tqdm/4.67.3 importlib-metadata/8.7.1 keyring/25.7.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.15

File hashes

Hashes for djangoldp-5.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b69381fc0f45d50c1ec1c8d02e8525c46892ed07c9157b667071386f0550966e
MD5 14b8919d825b99afdada013e100fb333
BLAKE2b-256 014560a437fa5180fe4513d3ab28d788cbf240055a30ecfc84d5ac273b198790

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page