Merge pull request #272 from q3aiml/response-type-natural-key
add natural key support to ResponseType
This commit is contained in:
commit
0effc32be2
1 changed files with 10 additions and 0 deletions
|
@ -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):
|
class ResponseType(models.Model):
|
||||||
|
objects = ResponseTypeManager()
|
||||||
|
|
||||||
value = models.CharField(
|
value = models.CharField(
|
||||||
max_length=30,
|
max_length=30,
|
||||||
choices=RESPONSE_TYPE_CHOICES,
|
choices=RESPONSE_TYPE_CHOICES,
|
||||||
|
@ -40,6 +47,9 @@ class ResponseType(models.Model):
|
||||||
max_length=50,
|
max_length=50,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def natural_key(self):
|
||||||
|
return self.value, # natural_key must return tuple
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return u'{0}'.format(self.description)
|
return u'{0}'.format(self.description)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue