#35848: Problem with UniqueConstraint on fields, one of which allows NULL value.
-------------------------------------+-------------------------------------
     Reporter:  Андрей               |                    Owner:  (none)
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  UniqueConstraint,    |             Triage Stage:
  nullable, null                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Андрей):

 The error falls from serializer.is_valid (it is
 rest_framework.exceptions.ValidationError):

 >>> from directories.views import MyModelViewSet
 >>> viewset = MyModelViewSet()
 >>> new_object = viewset.create(data={'name': 'test', 'measure': 1})
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "....views.py", line 15, in create
     serializer.is_valid(raise_exception=True)
   File "....venv\Lib\site-packages\rest_framework\serializers.py", line
 231, in is_valid
     raise ValidationError(self.errors)
 rest_framework.exceptions.ValidationError: {'name':
 [ErrorDetail(string='my model with this Name already exists.',
 code='unique')]}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35848#comment:8>
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/010701929a884984-01d3a1ca-ccdc-4d08-8191-e40c5a56936b-000000%40eu-central-1.amazonses.com.

Reply via email to