Extend django-model-utils and django-extensions.
Project description
django-rubble
Description
Extend django-model-utils and 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)
- Useful Model and Form fields
SimplePercentageField
- Several Useful Utility Functions
is_number
: checks if number could be coerced to afloat
ratio_to_whole
: .1 to 10; useful for percentages to "human"whole_to_ration
: 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)
- Clone the repository:
git clone https://github.com/WoosterTech/django-rubble.git
- 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.
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.md.
This project is licensed under the MIT License.
Contact
- Author: Karl Wooster
- Email: karl@woostertech.com
- Website: woostertech.com
License
MIT (see License)
Contributing
See CONTRIBUTING.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_rubble-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c226f8fe3eea7737e7de6bf306e555fb5338dcd565a3a7a3ae012d356fe38d |
|
MD5 | 84bf0868ef3e89eb8a36593f619dd12b |
|
BLAKE2b-256 | f90db13fc5a1d0e9f9da3148b9c6257afb9270fae6765c298d480c57b64e0d13 |