The Registry

Lorikeet’s Line Items, Delivery Addresses and Payment Methods are all made up of two components: a model and a serializer. In order to use them, Lorikeet needs to know about each serializer that’s available, and which model each one corresponds to.

There’s various ways that Lorikeet could associate the two automatically, but they’re all failure-prone and difficult to debug. Instead, Lorikeet exposes a registry at lorikeet.api_serializers.registry for you to declare those mappings manually.

Mappings can be declared by calling lorikeet.api_serializers.registry.register(). You can do this anywhere as long as it gets run when Django starts up, but the best place to do it is the ready() method of an AppConfig for your app:

from django.apps import AppConfig

class MyAppConfig(AppConfig):
    # ...

    def ready(self):
        from . import models, api_serializers
        from lorikeet.api_serializers import registry



If you’re newly setting up an app config for use with Lorikeet, make sure Django actually loads it!

You can do this by either changing your app’s entry in INSTALLED_APPS to the dotted path to your AppConfig (e.g. myapp.apps.MyAppConfig), or by adding a line like default_app_config = "myapp.apps.MyAppConfig" in your app’s

For more on app configs, check out the Django documentation.