我在项目中定义了一个图形结构,当前包含两种类型的节点:User和Post。我在Django框架上安装了neo4django并定义了models.py,如下所示:
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()
我想使用电子邮件地址和密码登录,然后电子邮件在数据库中必须是唯一的。我怎样才能在models.py中执行此操作?
答案 0 :(得分:1)
您可以将unique=True
传递给任何Property
子类。必须索引唯一属性,因此:
email = models.EmailProperty(indexed=True, unique=True)