#29747: UUID in loaddata fixture raise ValidationError on objects having
OneToOne
relationship (uuid as FK).
-------------------------------------+-------------------------------------
Reporter: stockersky | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 2.1
Severity: Normal | Resolution:
Keywords: uuid fixture | Triage Stage:
loaddata OneToOne | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by stockersky:
Old description:
> Hello,
>
> I was working on my django project with version 2.0.
> Today I redeployed my development environment and installed the lastest
> Django version through pip : 2.1.1
>
> While loading my database fixture to populate it (python manage.py
> loaddata data_fixture.json), it raised :
>
> {{{
> Traceback (most recent call last):
> File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
> packages/django/db/models/fields/__init__.py", line 2325, in to_python
> return uuid.UUID(value)
> File "/PROJECTS/SOFTWARES/python366/lib/python3.6/uuid.py", line 140,
> in __init__
> raise ValueError('badly formed hexadecimal UUID string')
> ValueError: badly formed hexadecimal UUID string
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
> packages/django/core/serializers/python.py", line 100, in Deserializer
> data[Model._meta.pk.attname] = Model._meta.pk.to_python(d.get('pk'))
> File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
> packages/django/db/models/fields/related.py", line 874, in to_python
> return self.target_field.to_python(value)
> File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
> packages/django/db/models/fields/__init__.py", line 2330, in to_python
> params={'value': value},
> django.core.exceptions.ValidationError: ["La valeur «\xa020\xa0» n'est
> pas un UUID valide."]
>
> ......................
>
> raise base.DeserializationError.WithData(e, d['model'], d.get('pk'),
> None)
> django.core.serializers.base.DeserializationError: Problem installing
> fixture
> '/PROJECTS/CODE/cv_project/cv_frontend/fixtures/data_fixture.json': ["La
> valeur «\xa020\xa0» n'est pas un UUID valide."]:
> (cv_frontend.PersonalInfo:pk=20) field_value was 'None'
>
> }}}
>
> I flushed migrations, dropper/recreate database and ran migrations again.
> Still has the error...
>
> I could actually still create the object having uuid as PK in the admin
> console and link other objects to it.
>
> == Then I began to delete objects in my fixture file and try to run again
> loaddata : when I deleted every fixture object that had OneToOne
> relationship, it passed!!!
>
> I finally rolled back to Django 2.0 and could run the whole fixture with
> no problem!
>
> Does it sound like a bug?
New description:
Hello,
I was working on my django project with version 2.0.
Today I redeployed my development environment and installed the lastest
Django version through pip : 2.1.1
While loading my database fixture to populate it (python manage.py
loaddata data_fixture.json), it raised :
{{{
Traceback (most recent call last):
File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
packages/django/db/models/fields/__init__.py", line 2325, in to_python
return uuid.UUID(value)
File "/PROJECTS/SOFTWARES/python366/lib/python3.6/uuid.py", line 140, in
__init__
raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
packages/django/core/serializers/python.py", line 100, in Deserializer
data[Model._meta.pk.attname] = Model._meta.pk.to_python(d.get('pk'))
File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
packages/django/db/models/fields/related.py", line 874, in to_python
return self.target_field.to_python(value)
File "/PROJECTS/SOFTWARES/pvenvs/cvdjango/lib/python3.6/site-
packages/django/db/models/fields/__init__.py", line 2330, in to_python
params={'value': value},
django.core.exceptions.ValidationError: ["La valeur «\xa020\xa0» n'est pas
un UUID valide."]
......................
raise base.DeserializationError.WithData(e, d['model'], d.get('pk'),
None)
django.core.serializers.base.DeserializationError: Problem installing
fixture
'/PROJECTS/CODE/cv_project/cv_frontend/fixtures/data_fixture.json': ["La
valeur «\xa020\xa0» n'est pas un UUID valide."]:
(cv_frontend.PersonalInfo:pk=20) field_value was 'None'
}}}
I flushed migrations, dropped/recreate database and ran migrations again.
Still had the error...
I could actually still create an object having uuid as PK in the admin
console and link other objects to it.
== Then I began to delete objects in my fixture file and try to run again
loaddata : when I deleted every fixture object that had OneToOne
relationship, it passed!!!
I finally rolled back to Django 2.0 and could run the whole fixture with
no problem!
Does it sound like a bug?
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29747#comment:2>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.28d84e4dcf570942535559d5860cb776%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.