I am pursuing the debug option now to see what I can learn. On Fri, Feb 19, 2016 at 5:29 PM, Michal Petrucha < michal.petru...@koniiiik.org> wrote:
> On Fri, Feb 19, 2016 at 10:20:42AM -0600, Malik Rumi wrote: > > In [1]: import uuid > > > > In [2]: uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74') > > Out[2]: UUID('61877565-5fe5-4175-9f2b-d24704df0b74') > > > > BUT > > > > In [3]: uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74') > > > --------------------------------------------------------------------------- > > AttributeError Traceback (most recent call > last) > > <ipython-input-3-8d12e49c94ea> in <module>() > > ----> 1 uuid.UUID4('61877565-5fe5-4175-9f2b-d24704df0b74') > > > > AttributeError: 'module' object has no attribute 'UUID4' > > > > > > So uuid.UUID4() [or 3 or whatever] can only be used a certain way, as in > > Michael's example? > > There's no such thing as UUID4 in the Python uuid module -- there's > UUID (which is the class representing UUIDs), and there's the function > uuid4 (note that it's lowercase, it takes no arguments, and it will > return an instance of UUID). > > > The remaining question for me, then, is *what is the proper format *for a > > uuid in a json fixture, or any other document I am trying to mass import > > into Django? > > > > 61877565-5fe5-4175-9f2b-d24704df0b74 - (apparently not) > > > > '61877565-5fe5-4175-9f2b-d24704df0b74' > > > > ('61877565-5fe5-4175-9f2b-d24704df0b74') > > > > UUID('61877565-5fe5-4175-9f2b-d24704df0b74') > > > > urn:uuid('61877565-5fe5-4175-9f2b-d24704df0b74') > > > > some other variation I haven't come up with yet? > > > > Here is a portion of my json document: > > > > [{"model": "essell.Code", "fields": { "uuid": > > "48189959-be4c-4f10-819a-f1657061b3cd", "arrow": "Amendment II", > > "shorttitle": "", "popularname": "Keep & Bear Arms", "acronym": "", > > "offcite": "", "brokenarrow": "", "slug": "amendment-ii-keep-bear-arms", > > "codetext": "A well regulated Militia, being necessary to the security > of a > > free State, the right of the people to keep and bear Arms, shall not be > > infringed.", "effdate": "1792-03-13", "sunsetdate": "", "sunsetcause": > > "''", "postdate": "2016-02-05 13:06:53.20548-06", "crossref": "''", > > "codekind": "Article", "codekindsortseq": "1", "codelevel": > "Constitution", > > "codelevelsortseq": "1", "siblingrank": "11", "childof_id": "", > > "jurisdiction_id": "e6e11b06-ea3b-4e98-a31f-9a83447ad884"} }, {"model" > > .... > > > > As you can see, the uuid is double quoted, but so are all the keys and > > values. This is normal json format as I understand it. So should the uuid > > be single quoted inside the double quotes? i.e. > > > > "'61877565-5fe5-4175-9f2b-d24704df0b74'" > > > > How do I get this done? Thanks. > > The two UUIDs in that JSON snippet look correct at a first (and > second) glance. Have you tried using a debugger, or just a > quick-and-dirty print statement to see what value is being passed into > uuid.UUID that makes it raise an exception? > > My guess would be that the JSON file contains a value somewhere that > is not a correct UUID, but I may be wrong, of course. > > Regards, > > Michal > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Django users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/django-users/Q4zybgExDyY/unsubscribe. > To unsubscribe from this group and all its topics, 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/20160219232920.GF880%40koniiiik.org > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAKd6oByNpxOM1DKAWZorUn_6EoV67Ez3G3k0xe-%2BxGN-7xa29A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.