https://github.com/jayvdb/djsommo
Django safe optional model Meta options
https://github.com/jayvdb/djsommo
django-models
Last synced: over 1 year ago
JSON representation
Django safe optional model Meta options
- Host: GitHub
- URL: https://github.com/jayvdb/djsommo
- Owner: jayvdb
- License: mit
- Created: 2020-06-17T15:06:55.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-17T18:18:16.000Z (about 6 years ago)
- Last Synced: 2025-03-10T22:17:37.507Z (over 1 year ago)
- Topics: django-models
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`
```py
from django.db import models
from djsommo import SafeOptionalMeta
class MyModel(models.Model):
uuid = models.TextField()
...
class Meta(SafeOptionalMeta):
unknown_option = True
```