# Django TypeID Field
TypeID is a type-safe extension of UUIDv7, encoding UUIDs in base32 and adding a type prefix. This package provides a field to use in models. For more details about TypeID, visit the [TypeID GitHub repository](https://github.com/jetify-com/typeid).
## Installation
Install it from PyPI:
```sh
pip install django-typeid-field
```
## Usage
First, add it to your applications (Not Required)
```python
INSTALLED_APPS = [
# ...
'typeid_field',
# ...
]
```
You can now use it in your models like:
```python
from django.db import models
from typeid_field import TypeidField
class Profile(models.Model):
hash = TypeidField(prefix='profile')
```
## TypeidField
This model field is based on `CharField`. All of it's parameters can be used.
Additionally following fields affects outcome of TypeID:
### `prefix` Parameter (Optional)
Specifies the type prefix for the generated TypeID, which impacts the length of the ID and the field in the database. The prefix can be up to 63 characters long, must contain only lowercase alphabetic ASCII characters or underscores, and cannot start or end with an underscore. If the prefix is empty, no separator is used.
## Using TypeidField as `primary_key`
To use TypeID as default `primary_key` you need to explicitly define it in your
model:
```python
from django.contrib.auth.models import AbstractUser
from django.db import models
class SomeModel(models.Model):
id = TypeidField(primary_key=True, editable=False) # 2x4y6z8a0b1c2d3e4f5g6h7j8k
# ...
class CustomUser(AbstractUser):
id = TypeidField(primary_key=True, editable=False, prefix='user') # user_2x4y6z8a0b1c2d3e4f5g6h7j8k
# ...
```
## Credits
This package is based on [django-nanoid-field](https://github.com/goztrk/django-nanoid-field).
Raw data
{
"_id": null,
"home_page": null,
"name": "django-typeid-field",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django, typeid, django-field",
"author": null,
"author_email": "mschfh <mschfh@proton.me>",
"download_url": "https://files.pythonhosted.org/packages/95/6f/186bb204d60d563b0b3d77b1588f72b7a5b0f13eb959fd167e1d027bca61/django_typeid_field-0.0.1.tar.gz",
"platform": null,
"description": "# Django TypeID Field\n\nTypeID is a type-safe extension of UUIDv7, encoding UUIDs in base32 and adding a type prefix. This package provides a field to use in models. For more details about TypeID, visit the [TypeID GitHub repository](https://github.com/jetify-com/typeid).\n\n## Installation\n\nInstall it from PyPI:\n\n```sh\npip install django-typeid-field\n```\n\n\n## Usage\n\nFirst, add it to your applications (Not Required)\n\n```python\nINSTALLED_APPS = [\n # ...\n 'typeid_field',\n # ...\n]\n```\n\nYou can now use it in your models like:\n\n```python\nfrom django.db import models\nfrom typeid_field import TypeidField\n\nclass Profile(models.Model):\n hash = TypeidField(prefix='profile')\n```\n\n\n## TypeidField\n\nThis model field is based on `CharField`. All of it's parameters can be used.\n\nAdditionally following fields affects outcome of TypeID:\n\n\n### `prefix` Parameter (Optional)\nSpecifies the type prefix for the generated TypeID, which impacts the length of the ID and the field in the database. The prefix can be up to 63 characters long, must contain only lowercase alphabetic ASCII characters or underscores, and cannot start or end with an underscore. If the prefix is empty, no separator is used.\n\n\n## Using TypeidField as `primary_key`\nTo use TypeID as default `primary_key` you need to explicitly define it in your\nmodel:\n\n```python\nfrom django.contrib.auth.models import AbstractUser\nfrom django.db import models\n\n\nclass SomeModel(models.Model):\n id = TypeidField(primary_key=True, editable=False) # 2x4y6z8a0b1c2d3e4f5g6h7j8k\n # ...\n\nclass CustomUser(AbstractUser):\n id = TypeidField(primary_key=True, editable=False, prefix='user') # user_2x4y6z8a0b1c2d3e4f5g6h7j8k\n # ...\n```\n\n\n## Credits\nThis package is based on [django-nanoid-field](https://github.com/goztrk/django-nanoid-field).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "TypeID Field for Django",
"version": "0.0.1",
"project_urls": {
"Documentation": "https://github.com/mschfh/django-typeid-field",
"Homepage": "https://github.com/mschfh/django-typeid-field",
"Repository": "https://github.com/mschfh/django-typeid-field.git"
},
"split_keywords": [
"django",
" typeid",
" django-field"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "781bbd157816040d911c0808feb08b34b702499dacd70ebfe3c17a5f23b5a2c5",
"md5": "c68a1898cce188ecb7166b6e52fe9091",
"sha256": "ab352779a077a053ef3ba3007412012de345323ea3137d7b4a1abedefd5bc1b1"
},
"downloads": -1,
"filename": "django_typeid_field-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c68a1898cce188ecb7166b6e52fe9091",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3910,
"upload_time": "2024-06-08T17:35:40",
"upload_time_iso_8601": "2024-06-08T17:35:40.207285Z",
"url": "https://files.pythonhosted.org/packages/78/1b/bd157816040d911c0808feb08b34b702499dacd70ebfe3c17a5f23b5a2c5/django_typeid_field-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "956f186bb204d60d563b0b3d77b1588f72b7a5b0f13eb959fd167e1d027bca61",
"md5": "29f5a4b4c8e9e271e8de8c1ec44f36db",
"sha256": "904abb2dd256b1a6d6182c2462eb8765c7d058da93f30b6a692d71bafeb387b8"
},
"downloads": -1,
"filename": "django_typeid_field-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "29f5a4b4c8e9e271e8de8c1ec44f36db",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3454,
"upload_time": "2024-06-08T17:35:41",
"upload_time_iso_8601": "2024-06-08T17:35:41.401082Z",
"url": "https://files.pythonhosted.org/packages/95/6f/186bb204d60d563b0b3d77b1588f72b7a5b0f13eb959fd167e1d027bca61/django_typeid_field-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-08 17:35:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mschfh",
"github_project": "django-typeid-field",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-typeid-field"
}