Metadata-Version: 2.1
Name: django-rubble
Version: 0.6.0
Summary: Extend django-model-utils and django-extensions.
Home-page: https://github.com/WoosterTech/django-rubble
License: MIT
Keywords: django,django-model-utils,django-extensions
Author: Karl Wooster
Author-email: karl@woostertech.com
Requires-Python: >=3.10,<4.0
Classifier: Framework :: Django :: 4
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: all
Provides-Extra: history
Provides-Extra: project
Requires-Dist: croniter (>=3.0.3,<4.0.0)
Requires-Dist: django (>4,<5.3)
Requires-Dist: django-model-utils (>=4.5.1,<5.0.0)
Requires-Dist: django-simple-history (>=3.7.0,<4.0.0) ; extra == "history" or extra == "all"
Requires-Dist: loguru (>=0.7.2,<0.8.0)
Requires-Dist: neapolitan (>=24.6,<25.0) ; extra == "project" or extra == "all"
Requires-Dist: pydantic (>=2.6.4,<3.0.0)
Project-URL: Bug Tracker, https://github.com/WoosterTech/django-rubble/issues
Project-URL: Change Log, https://github.com/WoosterTech/django-rubble/blob/main/CHANGELOG.md
Project-URL: Documentation, https://woostertech.github.io/django-rubble/
Project-URL: Repository, https://github.com/WoosterTech/django-rubble
Description-Content-Type: text/markdown

# django-rubble

[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![image](https://img.shields.io/pypi/v/django-rubble.svg)](https://pypi.python.org/pypi/django-rubble)
[![image](https://img.shields.io/pypi/pyversions/django-rubble.svg)](https://pypi.python.org/pypi/django-rubble)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)


## Description

Extend [django-model-utils](https://github.com/jazzband/django-model-utils) and [django-extensions](https://github.com/django-extensions/django-extensions).

>Version 0.4.0 code got deleted but still exists on PyPI.

## Features

- Serialized Number Generation (e.g. PN-0001, PN-0001; MY1, MY2)
    - [`NumberedModel`](models/number_models#django_rubble.models.number_models.NumberedModel)
- Useful Model and Form fields
    - [`SimplePercentageField`](fields/db_fields#django_rubble.fields.db_fields.SimplePercentageField)
- Several Useful Utility Functions
    - [`is_number`](utils/numbers#django_rubble.utils.numbers.is_number): checks if number could be coerced to a `float`
    - [`ratio_to_whole`](utils/numbers#django_rubble.utils.numbers.ratio_to_whole): .1 to 10; useful for percentages to "human"
    - [`whole_to_ratio`](utils/numbers#django_rubble.utils.numbers.whole_to_ratio): 10 to .1; useful for "human" to "percentages"
    - perhaps others, see docs when they're published

## Installation

### From PyPI

`pip install django-rubble`

### From GitHub (for development)

1. Clone the repository: `git clone https://github.com/WoosterTech/django-rubble.git`
2. Install the dependencies: `poetry install`

## Usage

Simply use the functions, fields, models.

The biggest "gotcha" is that `NamedSerialNumber` needs to be imported in your `urls.py` file; not actually sure why, perhaps someone can help me with that?

To use the automatic numbering, subclass `NumberedModel` and make sure to include a `number_config = SerialNumberConfig(...)` attribute. It will set defaults, but just as a standard integer starting at "1" with no prefix.

```python
class PartNumber(NumberedModel):
    name = models.CharField("Part Description", max_length=100)
    number_config = SerialNumberConfig(
        initial_value=10, prefix="PN-", width=4
    )
```

Numbers will be generated starting with "PN-0010" (note the padding to make a width of 4) and increment by the default step of "1."


Contributions are welcome! Please follow the guidelines in [contributing](/contributing/)


This project is licensed under the [MIT License](LICENSE).

## Contact

- Author: Karl Wooster
- Email: <karl@woostertech.com>
- Website: [woostertech.com](https://woostertech.com)

## License

MIT (see [License](LICENSE))

## Contributing

See [contributing](/contributing/)

