Пример #1
0
 def valid_value(self, value):
     text_value = force_text(value)
     for k, v in self.choices:
         if isinstance(k, type):
             k = classpath(k)
         if value == k or text_value == force_text(k):
             return True
     return False
Пример #2
0
    def _set_choices(self, value):
        choices = list(value)
        self._choices = choices

        text_choices = [(classpath(subclass) if subclass else subclass, name)
                        for subclass, name in choices]

        self.widget.choices = text_choices
Пример #3
0
 def valid_value(self, value):
     text_value = force_text(value)
     for k, v in self.choices:
         if isinstance(k, type):
             k = classpath(k)
         if value == k or text_value == force_text(k):
             return True
     return False
Пример #4
0
    def _set_choices(self, value):
        choices = list(value)
        self._choices = choices

        text_choices = [(
            classpath(subclass) if subclass else subclass,
            name
        ) for subclass, name in choices]

        self.widget.choices = text_choices
Пример #5
0
 def get_context(self, name, value, attrs):
     value = classpath(value)
     context = super(DashboardSelect, self).get_context(name, value, attrs)
     return context
Пример #6
0
 def render(self, name, value, attrs=None, choices=()):
     value = classpath(value)
     return super(DashboardSelect, self).render(
         name, value, attrs, choices)
Пример #7
0
 def render(self, name, value, attrs=None, choices=()):
     value = classpath(value)
     return super(DashboardSelect, self).render(name, value, attrs, choices)