![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
django-controlled-vocabulary
Advanced tools
This app provides models and admin interface to link your data to standard vocabularies (e.g. ISO language codes, Wikidata). Benefits: increases the consistency and understandability of your project data.
Requirements: Python 3.5+, Django 2.2+
Development Status: Beta
A ControlledTerm field in the Django admin interface. The user selects the vocabulary (here: Wikidata), then starts typing a term in the text box. Suggestions are brought from Wikidata. When the user saves the changes, information about the selected term is copied into the database (url, identifier, label).
Built-in plugins for the following authority files:
Vocabulary | Description |
---|---|
Schema.org | High-level categories of content |
Wikidata | High level concepts or specific instances (e.g. places, people) |
ISO 639-2 | Language codes |
DCMI Type | Dublin Core Format Type |
MIME | Media/File types |
FAST Topics | Topic categorisation |
FAST Forms and Genres | Genres of a piece of work |
VIAF | Various: regions, people, companies, ... |
Vocabularies | Terms |
---|---|
![]() | ![]() |
ControlledVocabulary
ControlledTerm
Conventions:
A Vocabulary plug-in / manager is a python class that provides services for a vocabulary:
Managers can provide terms from a CSV file downloaded from an authoritative source.
Some vocabularies can contain thousands of terms or more. A plugin will only insert the terms used by your application. The rest will be accessed on demand from a file on disk or in a third-party server. This approach saves database space and keeps your application data self-contained.
This project comes with built-in plugins such a Wikidata or Schema.org. Those plugins are enabled by default; see below how to selectively enable them.
This architecture allows third-party plugins to be supplied via separate python packages.
Install into your environment:
pip install django-controlled-vocabulary
Add the app to the INSTALLED_APPS list in your Django settings file:
INSTALLED_APPS = [
...
'controlled_vocabulary',
...
]
Add the following path to your project urls.py:
from django.urls import path, include
...
urlpatterns = [
...
path('vocabularies/', include('controlled_vocabulary.urls')),
...
]
Run the migrations:
./manage.py migrate
Download vocabulary data and add metadata to the database:
./manage.py vocab init
Currently all built-in plugins / managers are enabled by default. Add the following code in your settings.py to enable only specific vocabularies based on the import path of their classes. You can also use this to enable your own or third-party plugins.
# List of import paths to vocabularies lookup classes
CONTROLLED_VOCABULARY_VOCABULARIES = [
'controlled_vocabulary.vocabularies.iso639_2',
'controlled_vocabulary.vocabularies.dcmitype',
]
After enabling a new plug-in / manager, always run ./manage.py vocab init
.
Use the ControlledTermField field to define a field with an autocomplete to controlled terms in your Django Model:
from controlled_vocabulary.models import ControlledTermField
...
class MyModel(models.Model):
...
language_code = ControlledTermField(
'iso639-2',
null=True, blank=True
)
Where iso639-2
is the prefix of a controlled vocabulary in your database.
ControlledTermField is essentially syntactic sugar for a ForeignKeyField with an adapted Select widget.
For multiple values, you can use ControlledTermsField (note the 's' in the name), which inherits from ManyToManyField with an adapted SelectMultiple widget. The useage is identical but obviously null=True
should be omitted.
By default the widget proposes the given vocabulary to the end user, but they can use the dropdown to switch to any other available vocabulary (see screenshot at the top of this page). To lock the selection to a single vocabulary, use this expression instead:
language_code = ControlledTermField(
['iso639-2'],
null=True, blank=True
)
You can have more than one prefix in that list if you want. The first item is always the one proposed by default on page load.
vocab is a django command line tool that lets you manipulate the vocabularies and the plugins. To find out more use the help:
./manage vocab help
FAQs
Link your data to authority lists or your own controlled lists
We found that django-controlled-vocabulary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.