Skip to main content

django-institutions

A Django application that provides a university institution field for models and a serializer.

Installation

  • pip install django-institutions
  • Add django_institutions to your INSTALLED_APPS

Usage

InstitutionField

An institution field for Django models with choices from: https://github.com/Hipo/university-domains-list

InstitutionField is based on Django's CharField.

Consider the following model user InstitutionField:

from django.db import models
from django_institutions.fields import InstitutionField

class User(models.Model):
    name = models.CharField(max_length=255)
    institution = InstitutionField()

A User instance will have a institution attribute where you can get the details of the institution.

>>> user = User(name='John Doe', institution='University of London')
>>> user.institution
Institution(name='University of London', country='United Kingdom', etc)
>>> user.institution.name
'University of London'
>>> user.institution.country
'United Kingdom'

Django Rest Framework field

To serialize the institution field, you can use the InstitutionField serializer field. For example:

from django_institutions.serializer_fields import InstitutionField

class UserSerializer(serializers.ModelSerializer):
    institution = InstitutionField()

REST output format

The serialized output will look like the following:

{"name": "University of London"}

Either the dict output or simply the name of the institution is acceptable as intputs.

Acknowledgements

This project is inspired by django-countries

Thanks to SmileyChris for the inspiration.

Data

The institution data is sourced from university-domains-list

Notes

This project is still very in early development. Help is welcome :)

Download files

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

Source Distribution

django_institutions-0.0.5.tar.gz (205.9 kB view details)

Uploaded Source

Built Distribution

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

django_institutions-0.0.5-py3-none-any.whl (210.6 kB view details)

Uploaded Python 3

File details

Details for the file django_institutions-0.0.5.tar.gz.

File metadata

  • Download URL: django_institutions-0.0.5.tar.gz
  • Upload date:
  • Size: 205.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for django_institutions-0.0.5.tar.gz
Algorithm Hash digest
SHA256 4bc5b5d98886630c88d583649d040f89965cde499e2aaa75f8bfde47bfe9bcbf
MD5 65ecf5a01081a7d3d93843af95c2ccfd
BLAKE2b-256 6cf1d0c4190b936f807cd35fdfa51f94ed383826e27bdff10d9f8ffdb3dcaa8e

See more details on using hashes here.

File details

Details for the file django_institutions-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_institutions-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d5439435e6a8b3713bf092656565139102ec39bffa94052dfee00f7a1c536bb1
MD5 53ae9bbaeeb26e6a77540ca2b5b2f2d6
BLAKE2b-256 c5e65a81548660ce3f9e3b6fb1d3038b31a0599e0a693ee1e7aadfde03204dfa

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.6

2 files

This release

0.0.5 This release

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page