def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['page_chooser'].widget = AdminPageChooser() self.fields['image_chooser'].widget = AdminImageChooser() self.fields['document_chooser'].widget = AdminDocumentChooser() self.fields['snippet_chooser'].widget = AdminSnippetChooser(Page) self.fields['date'].widget = AdminDateInput() self.fields['time'].widget = AdminTimeInput() self.fields['datetime'].widget = AdminDateTimeInput() self.fields['auto_height_text'].widget = AdminAutoHeightTextInput() self.fields['default_rich_text'].widget = get_rich_text_editor_widget('default')
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["page_chooser"].widget = AdminPageChooser() self.fields["image_chooser"].widget = AdminImageChooser() self.fields["document_chooser"].widget = AdminDocumentChooser() self.fields["snippet_chooser"].widget = AdminSnippetChooser(Page) self.fields["date"].widget = AdminDateInput() self.fields["time"].widget = AdminTimeInput() self.fields["datetime"].widget = AdminDateTimeInput() self.fields["auto_height_text"].widget = AdminAutoHeightTextInput() self.fields["default_rich_text"].widget = get_rich_text_editor_widget( "default") self.fields["switch"].widget = SwitchInput() self.fields["disabled_switch"].widget = SwitchInput( attrs={"disabled": True})
def widget_overrides(self): return {self.field_name: AdminImageChooser(show_edit_link=False)}
from django import forms from django.utils.translation import ugettext_lazy as _ from wagtail.admin.rich_text import get_rich_text_editor_widget from wagtail.images.widgets import AdminImageChooser from ..service import _user_profiles, _users, _authors image_widget = AdminImageChooser( choose_one_text=_("Choose a photo"), choose_another_text=_("Choose a different photo"), ) class AuthorForm(forms.ModelForm): """ Form used by admins to register a new author with profile """ class Meta: model = _user_profiles.__model__ # fields = ('first_name', 'last_name') exclude = ("user", ) email = forms.EmailField(required=False, label=_("Email")) first_name = forms.CharField(required=True, label=_("First Name")) last_name = forms.CharField(required=True, label=_("Last Name")) field_order = ["email", "first_name", "last_name"] def clean_email(self): email = self.cleaned_data["email"]
def widget(self): from wagtail.images.widgets import AdminImageChooser return AdminImageChooser()