A Django app to generate model id based on a snowflake of twitter.
Project description
## Installation
1. Get the code: pip install uidgenerator-utils
2. Add "uidgenerator" to your INSTALLED_APPS
## Usage
* To use it in your model class:
```
from django.db import models
from uidgenerator.models import UIDField
class Tag(models.Model):
tag_id = UIDField(primary_key=True)
....
```
* if you want to change the default configuration, alter the parameter in settings:
```
UIDGENERATOR_START_TIMESTAMP = 1514736000000 #2018-1-1 0:0:0
UIDGENERATOR_REGIONIDBITS = 3
UIDGENERATOR_WORKERIDBITS = 10
UIDGENERATOR_SEQUENCEBITS = 10
UIDGENERATOR_REGIONID = 1
UIDGENERATOR_WORKERID = 1
```
1. Get the code: pip install uidgenerator-utils
2. Add "uidgenerator" to your INSTALLED_APPS
## Usage
* To use it in your model class:
```
from django.db import models
from uidgenerator.models import UIDField
class Tag(models.Model):
tag_id = UIDField(primary_key=True)
....
```
* if you want to change the default configuration, alter the parameter in settings:
```
UIDGENERATOR_START_TIMESTAMP = 1514736000000 #2018-1-1 0:0:0
UIDGENERATOR_REGIONIDBITS = 3
UIDGENERATOR_WORKERIDBITS = 10
UIDGENERATOR_SEQUENCEBITS = 10
UIDGENERATOR_REGIONID = 1
UIDGENERATOR_WORKERID = 1
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file uidgenerator_utils-0.4.1.tar.gz
.
File metadata
- Download URL: uidgenerator_utils-0.4.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9282f00a14eab7b8341a930aea33b68202375c4305639439755f43d8ab871afd |
|
MD5 | f9f1697c4f52b357667ab66aa3aee896 |
|
BLAKE2b-256 | ba750e1eea6125896b808c332adddabad8943fc79f1618255454b176d2276ff6 |