#23408: Add makemigrations warning for unique fields with callable defaults
-----------------------------+------------------------------------
     Reporter:  Harper04     |                    Owner:  nobody
         Type:  New feature  |                   Status:  new
    Component:  Migrations   |                  Version:  master
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by max13fr):

 Hello,

 I'm still running this issue on Django five years later, is there any hope
 to see this issue fixed ?

 I don't understand why default id with primary key (so is unique too)
 doesn't have the same issue.

 Default values are normally used only when we are not providing a value
 (or providing None value), so I don't understand why when I specify a
 value, Django just uses it instead of replace it with default value.

 What I'm missing ?

 If needed here my example:

 api/models.py :

 {{{
 class Model Test(models.Model):
     id = models.UUIDField(primary_key=True, default=uuid.uuid4,
 editable=False)
     name = models.CharField(max_length=100)
 }}}

 api/fixtures/initial_data.json :

 {{{
 {
     "model": "api.Test",
     "pk": "724ea599-10a2-49a1-be2f-c1fcb04d003e",
     "fields": {
         "name": "Test 1"
     }
 }, {
     "model": "api.Test",
     "pk": "6bcb72f0-099b-416d-8b2c-fcd0bef76cbf",
     "fields": {
         "name": "Test 2"
     }
 }
 }}}

 Thanks in advance
 Max

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23408#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.95aac25b4f2d218207c3781509d376c5%40djangoproject.com.

Reply via email to