Skip to main content

A django app for institutions model fields

Project description

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 :)

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_institutions-0.0.2.tar.gz (205.8 kB view details)

Uploaded Source

Built Distribution

django_institutions-0.0.2-py3-none-any.whl (210.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_institutions-0.0.2.tar.gz
  • Upload date:
  • Size: 205.8 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.2.tar.gz
Algorithm Hash digest
SHA256 a4a9a9c924af24d07da6b24f3bfbd5419a85d20e1e425d8a25dcc7174407ea17
MD5 1c46f95013f65ac2662353a5815ccd16
BLAKE2b-256 934078bbb4182706efb86a53412b822ac534372d6f039daaa44bdce951c9df15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_institutions-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 277b53d40c60ab3ae468b7034c3b547b057391a0909fefd8ab84aa7f5462e0d8
MD5 70045e7402f695d69cc8538623cb9777
BLAKE2b-256 458f4fb77cc85ccb37253a3c80221a0fc7348ccca7f66833bbf485a36c236944

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