Merge pull request #272 from q3aiml/response-type-natural-key

add natural key support to ResponseType
This commit is contained in:
Juan Ignacio Fiorentino 2018-08-20 18:13:28 -03:00 committed by GitHub
commit 0effc32be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,14 @@ JWT_ALGS = [
]
class ResponseTypeManager(models.Manager):
def get_by_natural_key(self, value):
return self.get(value=value)
class ResponseType(models.Model):
objects = ResponseTypeManager()
value = models.CharField(
max_length=30,
choices=RESPONSE_TYPE_CHOICES,
@ -40,6 +47,9 @@ class ResponseType(models.Model):
max_length=50,
)
def natural_key(self):
return self.value, # natural_key must return tuple
def __str__(self):
return u'{0}'.format(self.description)