I have a neomodel model:
class User(StructuredNode):
id = UniqueIdProperty()
username = StringProperty(unique_index=True)
email = StringProperty(unique_index=True)
password = StringProperty()
def save(self, *args, **kwargs):
self.password = make_password(self.password)
return super(User, self).save(*args, **kwargs)
When I save a new instance of such model in the console, I get a new User instance successfully, but when I retrieve all User objects from model, I get an empty resultset:
(AttractoraVenv) MacBook-Pro-de-Hugo:AttractoraBackend hugovillalobos$ python manage.py shell
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from users.models import User
>>> user = User(username='admin', email='admin@admin.com', password='secret').save()
>>> user
<User: {'id': '0d3b0aa56499414d8fb205ea1279662e', 'username': 'admin', 'email': 'admin@admin.com', 'password': 'pbkdf2_sha2
56$150000$vTdAnqAvXnOM$0hPMc1KiMpLvHbVO4C77OXUa9dmKzt9lMxIg8Ig+za8='}>
>>> User.nodes.all()
[]
I don't know what I am missing.
EDIT
I found that when I create a User instance using cypher from neo4j console, User.nodes.all()
returns such instance. So I guess the problem is on User.save()
. I also found that User.save()
works well when updating, so the problem is on create.