django-choices-enums
The enum type used for Django choices enables Django’s choices to support code prompts!!
用于django choices的枚举类型,使得django的choices支持代码提示!!
依赖
python3+
Installation
pip install django-choices-enums
Usage
from django_choices_enums import DjangoChoicesEnum
class TypeChoices(DjangoChoicesEnum):
Created = (1,'created')
Finished = (2,'finished')
class Foo(models.Model):
type = models.IntegerField(choices=TypeChoices.to_django_choices())
use enum like this:
f = Foo.create(type=TypeChoices.Created)
get all values:
print(TypeChoices.all_values())
# Out: [1, 2]
anonymous values:
from django_choices_enums import DjangoChoicesEnum
class MyEnum(DjangoChoicesEnum):
A = (1, 'xxx')
B = (2, 'xxx')
anonymous = ((3, 'xx'),
(4, 'xx'),
)
print(MyEnum.all_values())
# Out: [(1, 'xxx'), (2, 'xxx'), (3, 'xx'), (4, 'xx')]
get verbose:
from django_choices_enums import DjangoChoicesEnum
class MyEnum(DjangoChoicesEnum):
A = (1, 'A ...')
B = (2, 'B ...')
anonymous = ((3, '33'),
(4, '44'),
)
print(MyEnum.A.verbose)
# Out: A ...
print(MyEnum.get_verbose(2))
# Out: B ...
print(MyEnum.get_verbose(3))
# Out: 33
print(MyEnum.get_verbose(MyEnum.B))
# Out: B ...
Metadata
Release files for django-choices-enums 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-choices-enums-1.0.3.tar.gz | 2.5 kB | Without provenance | Details for django-choices-enums-1.0.3.tar.gz |
Release files / django-choices-enums-1.0.3.tar.gz
| Download URL | django-choices-enums-1.0.3.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1073c4f25cf80d9e5b482fdba600250a6f993ce85c3127d32b764507f86d2814
|
|
BLAKE2b-256 checksum How to use checksums |
d3202c01ae7d974230b18f589fbbafaf183910fa99f194b2bf60f5c3a13b171c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4
|
Security for django-choices-enums 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.