semvec/pypi-packages huggingface dataset:
dj-enum 0.0.3
A Django enum field
Requires Python: >=3.6, <4
Keywords: dj_enum

# dj_enum
[![Checks & Tests](https://github.com/themrinalsinha/dj_enum/actions/workflows/checks_and_tests.yaml/badge.svg)](https://github.com/themrinalsinha/dj_enum/actions/workflows/checks_and_tests.yaml)

It includes a `StateChoiceField` that comes with reusable `TextChoices` and validation for state changes. This feature enhances flexibility and data integrity.

## Requirements
- Python 3.6+
- Django 2.2+

## Installation
To set up `dj_enum`, you can easily install it with pip.
```shell
$ pip install dj_enum
```

## Example
Consider a scenario where we have a model called `Order` that includes the storage of the order's payment status. This payment status can fall into one of the following in `PaymentStatus`.

It also defines the state transitions that are allowed for each state. For example, a payment status of `IN_PROGRESS` can only be changed to `FAILED` or `COMPLETED`. This is done by defining the `__states__` attribute in the `PaymentStatus` class which extends `StateEnum`.
```python
class PaymentStatus(StateEnum):
    NOT_STARTED = "not_started", "Not Started"
    IN_PROGRESS = "in_progress", "In Progress"
    COMPLETED = "completed", "Completed"
    FAILED = "failed", "Failed"
    CANCELLED = "cancelled", "Cancelled"
    NOT_REQUIRED = "not_required", "Not Required"

    __states__ = {
        NOT_STARTED: (),
        IN_PROGRESS: (NOT_STARTED, FAILED),
        FAILED: (IN_PROGRESS,),
        COMPLETED: (IN_PROGRESS, NOT_REQUIRED),
        NOT_REQUIRED: (IN_PROGRESS,),
        CANCELLED: (NOT_STARTED, NOT_REQUIRED, FAILED, COMPLETED),
    }
```
Model `Order` can be defined as follows. The `payment_status` field is defined as a `StateChoiceField` with the `PaymentStatus` enum class.
```python
class Orders(models.Model):
    product_name = models.CharField(max_length=100)
    payment_status = StateChoiceField(
        PaymentStatus, default=PaymentStatus.NOT_STARTED, max_length=20
    )
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
```

**Usage**
```shell
>>> order = Order.objects.create(product_name="Product 1")
>>> order.payment_status
<PaymentStatus.NOT_STARTED: 'not_started'>

>>> order.payment_status = PaymentStatus.IN_PROGRESS
>>> order.save()

>>> order.payment_status
<PaymentStatus.IN_PROGRESS: 'in_progress'>

# Now, if we try to change the payment status to CANCELLED, it will raise a InvalidTransitionError error.
>>> order.payment_status = PaymentStatus.CANCELLED

dj_enum.exceptions.InvalidTransitionError: [in_progress -> cancelled is not a valid transition for PaymentStatus']
```
py3blox 2.0.0
Pyblox is a  object-oriented asynchronous Python wrapper for the Roblox web API.
Requires Python: >=3.7

<p align="center" width="100%">
    <img src="https://raw.githubusercontent.com/invalidkaro/pyblox/main/resources/textlogo.svg" alt="pyblox" height="128em" />
    <br />
</p>
<p align="center">
    <a href="https://github.com/invalidkaro/pyblox">GitHub</a> |
    <a href="https://discord.gg/">Discord</a> |
    <a href="https://pypi.org/project/pyblox/">PyPI</a> |
    <a href="https://pyblox-docs.invalidkaro.dev">Documentation</a> |
    <a href="https://github.com/invalidkaro/pyblox/tree/main/examples">Examples</a> |
    <a href="https://github.com/invalidkaro/pyblox/blob/main/LICENSE">License</a>
</p>
<p align="center">
    <a href="https://discord.gg/UKPaPu4teg"><img src="https://img.shields.io/discord/761603917490159676?style=flat-square&logo=discord" alt="RoAPI Discord"/></a>
    <a href="https://pypi.org/project/invalidkaro/"><img src="https://img.shields.io/pypi/v/roblox?style=flat-square" alt="pyblox PyPI"/></a>
    <a href="https://pypi.org/project/roblox/"><img src="https://img.shields.io/pypi/dm/roblox?style=flat-square" alt="pyblox PyPI Downloads"/></a>
    <a href="https://pypi.org/project/roblox/"><img src="https://img.shields.io/pypi/dm/invalidkaro?style=flat-square" alt="pyblox PyPI Downloads (Legacy)"/></a>
    <a href="https://pypi.org/project/invalidkaro/"><img src="https://img.shields.io/pypi/l/roblox?style=flat-square" alt="pyblox PyPI License"/></a>
    <a href="https://github.com/invalidkaro/pyblox"><img src="https://img.shields.io/github/commit-activity/w/rbx-libdev/pyblox?style=flat-square" alt="pyblox GitHub Commit Activity"/></a>
    <a href="https://github.com/invalidkaro/pyblox"><img src="https://img.shields.io/github/last-commit/rbx-libdev/pyblox?style=flat-square" alt="pyblox GitHub Last Commit"/></a>
</p>

# Overview
Welcome to pyblox! pyblox is an asynchronous, object-oriented wrapper for the Roblox web API.

# Features
The key features are:  

- **Asynchronous**: pyblox works well with asynchronous frameworks like [FastAPI](https://fastapi.tiangolo.com/) and 
[discord.py](https://github.com/Rapptz/discord.py).  
- **Easy**: pyblox's client-based model is intuitive and easy to learn for both the beginner and expert developer. It
  abstracts away API requests and leaves you with simple objects that represent data types on the Roblox platform.
- **Flexible**: pyblox's builtin Requests object allows the user to do things that we haven't already implemented
ourselves without dealing with advanced Roblox-specific concepts.

# Installation
To install pyblox from PyPI, you can install with pip:
```
pip install roblox
```

To install the latest unstable version of pyblox, install [git-scm](https://git-scm.com/downloads) and run the following:
```
pip install git+https://github.com/invalidkaro/pyblox.git
```

# Tutorial
Learn how to use pyblox in our docs:
https://https://pyblox-docs.invalidkaro.dev/dev/tutorial/