Created
May 9, 2017 19:11
-
-
Save f-ewald/24e41039ccf6168f067a7bdca17fb639 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OptimizationJob(models.Model): | |
| def generate_primary_key(): | |
| no = randint(13537086546263552, 839299365868340223) | |
| str_no = Base62.encode(no) | |
| result_count = OptimizationJob.objects.filter(job_id=str_no).count() | |
| while result_count > 0: | |
| no = randint(13537086546263552, 839299365868340223) | |
| str_no = Base62.encode(no) | |
| result_count = OptimizationJob.objects.filter(job_id=str_no).count() | |
| return str_no | |
| job_id = models.CharField(max_length=10, primary_key=True, default=generate_primary_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment