Search code examples
djangodjango-modelsneo4jneo4django

Node properties not created when using neo4django


I have a Model in django created with neo4django.

class Person(models.NodeModel):
    """
    Persons of a Company
    """
    email = models.EmailProperty(required=True, unique=True, indexed=True,
                                 name=_(u'email'),
                                 verbose_name=_(u'person email address'),
                                 help_text=_(u'bla bla bla some help text'))
    full_name = models.StringProperty(name=_(u'Person full name'))

    # Neo4J Relationships
    role = models.Relationship(Role, rel_type='has_role',
                                     direction='Outgoing',
                                     related_name='persons')
    company = models.Relationship(Company, rel_type='works_to',
                                           direction='Outgoing',
                                           related_name='employees')

I try on the django shell

>>> p = Person.objects.create(email=u'[email protected]')
>>> p.id
6
>>> Person.objects.get(id='6')
<Person: Person object>
>>> Person.objects.get(email=u'[email protected]')
Traceback [bla bla bla]
[...]
DoesNotExist: Person matching query does not exist.
>>>

I also checked on the Neo4J web interface and I see the created node, but without any properties!

This problem looks like the one mentioned here but I am not sure if this is the same issue.

I have Django 1.4.5 and Neo4J 1.8.2


Solution

  • Matt thanks a lot for your recommendation. I always run the master git version.

    I upgraded to Django 1.5.1 and the problem disappeared. I still run the 1.8.2 version of Neo4J.

    UPDATE

    Trying to figure it out, I reverted back to Django 1.4.5 and after some research, I discovered, that the problem was actually because of the name attribute on the node properties.

    So if I change this

    full_name = models.StringProperty(name=_(u'Person full name'))
    

    to this

    full_name = models.StringProperty(verbose_name=_(u'Person full name'))
    

    or this

    full_name = models.StringProperty()
    

    then everything works as expected.

    Actually the name issue exists even if you upgrade to Django 1.5.1 so I guess there is some issue creating the properties when having a name attribute in it.