Skip to main content

A Django app that provides a model layer and tools for DCAT applications.

Project description

django-dcat is a Django app that provides a model layer for DCAT 3.0 metadata and some command line tools to import data to it, to create vocabularies and more.

If you wanna see an example of what can be done checkout Catalogo Social, a data catalog implemented with django-dcat.

Quick start

  1. Install the package using pip:

    pip install django-dcat
  2. Add “dcat” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...,
        "dcat",
    ]
  3. Run python manage.py migrate to create the DCAT models in your database.

  4. Start the development server and visit http://127.0.0.1:8000/admin/ to start adding data (you’ll need the Admin app enabled).

  5. Run python manage.py --help to see the available commands.

CLI utilities

Migrating from CKAN

There are two commands that allows you to:

  1. Make a dump of data from a CKAN data portal (that has ckanext-datajson installed)

  2. Create a Catalog with its related entities (datasets, distributions, etc)

# Download the data.json file from the portal
$ wget -O data.json https://www.ckan-example.org/data.json

# Download all files from the portal (by default in a data/ folder)
$ python manage.py dump_from_datajson

# Import all data and files into a local catalog
$ python manage.py import_from_datajson

Controlled vocabularies for standardise metadata

There are two commands to import controlled vocabularies used in the EU Open Data Portal in order to standardise the metadata.

# Populate records for the MediaType model (CSV, PDF, etc)
$ python manage.py import_filetypes

# Populate records for Licences (MIT, Apache, etc)
$ python manage.py import_licences

The goal of these commands is to provide data publishers with pre-filled options for the metadata fields. This will improve data quality and avoid common problems like duplicated metadata values for typos or inconsistent data entry (like distributions with .csv, .CSV, CSV, etc)

DCAT Serialization

Every object contains methods to serialize it to different formats. This way it is easy to implement a feed URL for your catalog.

  • catalog.to_jsonld(): (WIP) exports the catalog to a JSONLD format. The implementation has been inspired by the FAO - Data in Emergencies feed.

  • catalog.to_turtle(): TODO

  • catalog.to_rdf(): TODO

Extending the model

django-dcat focuses on providing a model layer for DCAT metadata. However, if you require custom fields in your application, you can extend any model using a OneToOneField pattern (similar to what you use to extend Django’s User model).

from django.db import models
from dcat.models import Distribution


class DistributionExtras(Distribution):
    distribution = models.OneToOneField(Distribution, on_delete=models.CASCADE, related_name='extras')
    my_extra_field = models.CharField(max_length=255, blank=True, null=True)

And then you can call this fields from your code using the related name attribute:

from dcat.models import Distribution

distribution = Distribution.objects.get(pk=1)
print(distribution.extras.my_extra_field)

Note: Instead of calling it extras You can play with more semantic names for the related_name attribute like the name of your app.

Implementation notes

The Django models in this package are inspired by the diagram presented in DCAT profiles.

See the diagram: UML diagram illustrating the DCAT-AP specification

For more information on DCAT:

Publishing a new Version

The project uses twine to publish to PyPi:

  • Update the version in setup.cfg

  • Create a new release in Github.

  • Build the package: python -m build

  • Upload to PyPi twine upload dist/*

Project details


Download files

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

Source Distribution

django_dcat-0.0.9.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

django_dcat-0.0.9-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file django_dcat-0.0.9.tar.gz.

File metadata

  • Download URL: django_dcat-0.0.9.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for django_dcat-0.0.9.tar.gz
Algorithm Hash digest
SHA256 bc26e2874a8f963061c492f908fd28c7264289ab3d948dea20ff73d3c65b641b
MD5 717e12dbd3e8d117bedea1eb2c7461be
BLAKE2b-256 d2748a68482cbf17c57e5241959dfb386cc6d4df3e3cbc6d99143bca1f24877d

See more details on using hashes here.

File details

Details for the file django_dcat-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: django_dcat-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for django_dcat-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 208a7b691ce38517a5c8be893070a5259ce1cae49935b30773f54795acfdaddb
MD5 9a2896d3e6146e03a1b763d12a09a600
BLAKE2b-256 40d4605728939793cc137b8a0620751730a082afe32b913428dd8bdc8ce86cd6

See more details on using hashes here.

Supported by

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