Beispiel #1
0
    def formfield(self, form_class=TagField, **kwargs):
        defaults = {
            "label": _("Tags"),
            "help_text": _("A comma-separated list of tags."),
            "required": not self.blank,
            "widget": TagAutoSuggest(),
        }
        defaults.update(kwargs)

        return form_class(**defaults)
Beispiel #2
0
class AdvancedSearchForm(forms.Form):
    application = forms.ModelChoiceField(queryset=Application.objects.all(), label=_l("Application"), required=False)
    component = forms.ModelChoiceField(queryset=Component.objects.all(), label=_l("Component"), required=False)
    license = forms.ModelChoiceField(queryset=License.objects.all(), label=_l("License"), required=False)
    author = forms.ModelChoiceField(queryset=User.objects.all(), label=_l("Author"), required=False)
    original_author = forms.CharField(label=_l("Original author"), required=False)
    title = forms.CharField(label=_l("Title"), required=False)
    tags = TagAutoSuggest(Tag)
    version = VersionField(label=_l("Asset version"), required=False)
    app_version = VersionField(label=_l("Application version"), required=False)
 def formfield(self, form_class=TagField, **kwargs):
     tagmodel = "%s.%s" % (self.rel.to._meta.app_label,
                           _model_name(self.rel.to))
     defaults = {
         "label": capfirst(self.verbose_name),
         "help_text": self.help_text,
         "required": not self.blank,
         "widget": TagAutoSuggest(tagmodel=tagmodel),
     }
     defaults.update(kwargs)
     return form_class(**defaults)
Beispiel #4
0
 def formfield(self, form_class=TagField, **kwargs):
     if hasattr(self, 'rel'):  # Django < 1.9
         related_model = self.rel.to
     else:  # Django >= 1.9
         related_model = self.remote_field.model
     tagmodel = "%s.%s" % (related_model._meta.app_label,
                           _model_name(related_model))
     defaults = {
         "label": capfirst(self.verbose_name),
         "help_text": self.help_text,
         "required": not self.blank,
         "widget": TagAutoSuggest(tagmodel=tagmodel),
     }
     defaults.update(kwargs)
     return form_class(**defaults)
Beispiel #5
0
 def __init__(self, *args, **kwargs):
     super(LatestEntriesForm, self).__init__(*args, **kwargs)
     self.fields['tags'].widget = TagAutoSuggest('taggit.Tag')
Beispiel #6
0
 def __init__(self, *args, **kwargs):
     super(NewsAdminForm, self).__init__(*args, **kwargs)
     self.fields['tags'].widget = TagAutoSuggest('taggit.Tag')
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.fields["tags"].widget = TagAutoSuggest("taggit.Tag")