>
>
> Last night before posting I hacked serializers/python.py to make an
> exception for sunsetdate, and that apparently worked, but now I have this:
>

Yeah...don't do that. Fix your data.


> File
> "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
> line 2390, in get_db_prep_value
>
>              value = uuid.UUID(value)
>
>              File "/usr/lib/python2.7/uuid.py", line 134, in __init__
>
>              raise ValueError('badly formed hexadecimal UUID string')
>
> ValueError: Problem installing fixture
> '/home/malikarumi/Projects/cannon/jamf/essell/fixtures/test22byhand.json':
> badly formed hexadecimal UUID string
>
> The only uuid currently in this fixture is the one I got from Django when
> I put another model (only one row) in with a fixture (no date field) and it
> worked. I needed the uuid of that object to put into the foreign key of the
> model I am having trouble with now.
>

The uuid.UUID() function is somewhat forgiving when it comes to providing
values. See https://docs.python.org/3.5/library/uuid.html. Does the UUID in
your JSON data match any of those formats? The only common format for a
UUID that I've seen that doesn't match any of those formats would be
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' which is a string that contains
dashes, but no surrounding braces. I believe that's the format that is
pulled when using UUID's from Django installations by default. I'm actually
surprised the Python UUID library doesn't support it, but maybe it's one of
those RFC things that specifies the formats that must be accepted.


> Finally, this morning after reading your responses I decided to try
> putting in null with no comma, since I had already tried it with no quotes,
> and of course that didn't work. But then in fooling with it I put null in
> right next to the colon, with no spaces or quotes, followed by a comma, and
> this time null turned blue in my code editor, which suggests it was
> working. But then I got the 'badly formed hexadecimal UUID string error
> again.
>

JSON has rules for how data should be formatted. You may want to look those
up for guidelines.

> In sum, there is a special syntax to using null which is not obvious, but
> thanks for making me take another look and try again. The uuid error seems
> to be something else. There is a bugfix on github from November of 2014, so
> I don't (yet) know why I'm having this issue. I may post that later as a
> separate question. Thanks again!
>
>
Out of curiosity, did you generate the JSON manually, or did you use a
library (like the built-in JSON library in Python) to create the data dump
for you? From the sound of it, either you've mucked with it a bunch
yourself (which almost always leads to these types of issues with JSON), or
it was generated manually to look like JSON. Any proven serializer library
likely wouldn't generate data that resulted in the errors that you are
seeing (at least as far as the null issue is concerned). It would be
possible to get a 'malformed' UUID, since the serializer may not have been
configured correctly or aware of the intended format for the UUID values,
but would still have generated valid JSON.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVMREomNdie_ffKS619roWsZ5qHzAxKC1JDSST2U5RKRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to