0

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?

Ry-
  • 218,210
  • 55
  • 464
  • 476
mojibuntu
  • 307
  • 3
  • 16

1 Answers1

1

You can pass unique=True to any Property subclass. Unique properties have to be indexed, so:

email = models.EmailProperty(indexed=True, unique=True)
knbk
  • 52,111
  • 9
  • 124
  • 122
  • i get this error when run `python manage.py syncdb` : `ValueError: A unique property must be indexed.` – mojibuntu Aug 10 '13 at 16:58
  • thanks.this works .where are you find this parameters :D ? I don't find them do you find them in a specifiec resource ? – mojibuntu Aug 10 '13 at 18:51
  • 1
    @mojibuntu The Source Code is your biggest friend... In the mysterious lands of Github you'll find the answers you so desperately seek. – knbk Aug 10 '13 at 19:01