About Primary Keys of UUID Type
Don't set the default
value for UUID primary keys, because it will be evaluated at initialization and you won't be able to easily check if an instance is already saved or not. Use the save()
method instead to assign the value.
1 2 3 4 5 6 7 8 9 10 |
|
This way you can check in your Python code or templates:
1 2 3 4 |
|
Tips and Tricks Programming Architecture Django 4.2 Django 3.2 Django 2.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.