Skip to main content

Reusable Django app to safely use non-core optional model Meta options

Project description

djsommo

Django safe optional model Meta options.

Django doesn't support adding third-party fields to the model class Meta. It raises an exception if one is encountered.

Many installable apps inject a model Meta option name into Django during initialisation, after which it is safe to use them.

However what happens if the installable app isnt working for some reason, and you want to disable it.

Then you need to remove all use of the Meta option from the models.

This app provides a Meta class which detects unknown options, issues a warning and discards them before Django can raise an exception.

Usage

In models.py

from django.db import models

from djsommo import SafeOptionalMeta


class MyModel(models.Model):
    uuid = models.TextField()
    ...
    class Meta(SafeOptionalMeta):
        unknown_option = True

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

djsommo-0.2.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

djsommo-0.2.1-py2.py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 2 Python 3

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