scholrly / neo4django

Drop-in Neo4j/Django integration.
GNU General Public License v3.0
357 stars 83 forks source link

get_FOO_display #250

Open tapia opened 10 years ago

tapia commented 10 years ago

neo4django allows a choices parameter when defining a property. With the Django model properties you can use that to show the choice value (documentation), but, AFAIK, you can't do that with neo4django.

I mean something like this:

class User(models.NodeModel):
    GENDER_MALE = 1
    GENDER_FEMALE = 2
    GENDER_CHOICES = (
        (GENDER_MALE, _(u"Male")),
        (GENDER_FEMALE, _(u"Female")),
    )
    gender = models.IntegerProperty(choices=GENDER_CHOICES, default=GENDER_MALE)

This way we can build an internacionalized template using that field, while storing just an integer in our node:

<div class="gender">
    {{ user.get_gender_display }}
</div>

Is there any way (or expected way) we can achieve this with neo4django?