How do I hide the field label for a HiddenInput widget in Django Admin?

前端 未结 10 1043
谎友^
谎友^ 2020-12-31 02:34

I\'ve got a bit of Django form code that looks like this:

class GalleryAdminForm(forms.ModelForm):
    auto_id=False
    order = forms.CharField(widget=forms         


        
10条回答
  •  被撕碎了的回忆
    2020-12-31 03:31

    I think it's simpler to achieve the ":" label omission for HiddenInput widget by modifying class AdminField(object) in contrib/admin/helpers.py from :

        if self.is_checkbox:
            classes.append(u'vCheckboxLabel')
            contents = force_unicode(escape(self.field.label))
        else:
            contents = force_unicode(escape(self.field.label)) + u':'
    

    to :

        if self.is_checkbox:
            classes.append(u'vCheckboxLabel')
            contents = force_unicode(escape(self.field.label))
        else:            
            contents = force_unicode(escape(self.field.label))
            #MODIFIED 26/10/2009
            if self.field.label <> '':
               contents += u':'
            # END MODIFY
    

提交回复
热议问题