scholrly / neo4django

Drop-in Neo4j/Django integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NodeModelManager.get_or_create() fails when european characters are involved

tonjo opened this issue · comments

Storing names like "Città" in Neo4j gives error
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordinal not in range(128)

So I decode the string as utf8 and everything seems good:

City.objects.get_or_create(name='Città'.decode('utf8'))
(<City: City object>, True)

True: is created.
If I try again:

City.objects.get_or_create(name='Città'.decode('utf8'))
(<City: City object>, True)

True, created again

City.objects.get_or_create(name='Città'.decode('utf8'))
(<City: City object>, True)
... and again.

using decode with standard characters gives no problems:

City.objects.get_or_create(name='SimCity'.decode('utf8'))
(<City: City object>, True)
City.objects.get_or_create(name='SimCity'.decode('utf8'))
(<City: City object>, False)