Search code examples
pythondjangofloating-pointneo4jneo4django

how to store a float value on a neo4django model


I am writing an app using django 1.4.5 and neo4django (github version). I have created a model

e.g.

class FloatValues(models.NodeModel):
    a_float_value = models.StringProperty()

It looks like there is no a float property in neo4django, so I am thinking that I should either use a StringProperty or use an IntArrayProperty.

What is the best way to store a float value? (besides implementing a FloatProperty)


Solution

  • I'm going to go with- implementing a FloatProperty :) Really, it should already be in neo4django. Here's a simple implementation that doesn't support indexing.

    class FloatProperty(Property):
        def get_default(self):
            return 0.0
    
        def to_neo(self, value):
            return float(value)
    

    I'll raise an issue and try to get a real implementation out for the next release.