I've defined a graph structure in my project that currently contains 2 type of nodes: User and Post. I have installed neo4django on Django framework and define models.py like below:
from neo4django.db import models
class User(models.NodeModel):
#firstname of the user that registered in first time
firstName = models.StringProperty(max_length=20)
#lastname of the user that registered in first time
lastName = models.StringProperty(max_length=20)
#password of user that selected by user
password = models.StringProperty(max_length=50)
#email that use for verification
email = models.EmailProperty()
#status of the user that can be 1 for online and 0 for offline
status = models.BooleanProperty()
#date of birth that user selected from the register form
#BirthDate = models.DateProperty()
#sex of the user that can be male and female (0=male,1=female)
gender = models.BooleanProperty()
I want to use the email address and password for login then email must be unique in the database. How can I do this in models.py?
You can pass unique=True
to any Property
subclass. Unique properties have to be indexed, so:
email = models.EmailProperty(indexed=True, unique=True)