Avoid triggering migration creation using functions for choices and validators choices.

This commit is contained in:
Roberto Rosario
2015-07-07 21:21:08 -04:00
parent 7a11fddcc1
commit 0e81ea2ab8
5 changed files with 78 additions and 2 deletions
+5 -1
View File
@@ -11,6 +11,10 @@ from .managers import MetadataTypeManager
from .settings import setting_available_validators
def validation_choices():
return zip(setting_available_validators.value, setting_available_validators.value)
@python_2_unicode_compatible
class MetadataType(models.Model):
"""
@@ -27,7 +31,7 @@ class MetadataType(models.Model):
lookup = models.TextField(blank=True, null=True,
verbose_name=_('Lookup'),
help_text=_('Enter a string to be evaluated that returns an iterable.'))
validation = models.CharField(blank=True, choices=zip(setting_available_validators.value, setting_available_validators.value), max_length=64, verbose_name=_('Validation function name'))
validation = models.CharField(blank=True, choices=validation_choices(), max_length=64, verbose_name=_('Validation function name'))
# TODO: Find a different way to let users know what models and functions are
# available now that we removed these from the help_text
objects = MetadataTypeManager()