项目作者: jayvdb

项目描述 :
Django safe optional model Meta options
高级语言: Python
项目地址: git://github.com/jayvdb/djsommo.git
创建时间: 2020-06-17T15:06:55Z
项目社区:https://github.com/jayvdb/djsommo

开源协议:MIT License

下载


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

  1. from django.db import models
  2. from djsommo import SafeOptionalMeta
  3. class MyModel(models.Model):
  4. uuid = models.TextField()
  5. ...
  6. class Meta(SafeOptionalMeta):
  7. unknown_option = True