class Meta: widgets = { 'options': JSONEditor(), 'geolocations': JSONEditor(), 'username': forms.TextInput(attrs={'autocomplete': 'off'}), 'password': PasswordWidget(attrs={'autocomplete': 'off'}), }
class ProblemCreateForm(forms.ModelForm): class Meta: model = MultipleChoiceQuestion fields = ('title', 'token_value', 'difficulty', 'text', 'answer', 'tutorial', 'category', 'variables', 'choices') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['category'].widget.attrs.update({'class': 'form-control'}) self.fields['difficulty'].widget.attrs.update( {'class': 'form-control'}) title = forms.CharField(widget=TextInput(attrs={'class': 'form-control'})) token_value = forms.IntegerField(widget=NumberInput( attrs={'class': 'form-control'})) text = forms.CharField(label='Statement', widget=RichTextWidget(field_settings='advanced')) answer = forms.CharField(widget=Textarea(attrs={'class': 'form-control'})) tutorial = forms.CharField(widget=RichTextWidget( field_settings='advanced')) variables = forms.CharField(widget=JSONEditor(), help_text=""" It should be an array with each element a set of variables to choose. A valid example: [ { "x" : 1, "y" : 2, }, { "x" : 5, "y" : 8, } ] """) choices = forms.CharField(widget=JSONEditor(), help_text=""" It should be an object of choices. A valid example: { "a" : "{x} is odd and {y} is odd", "b" : "{x} is even and {y} is odd", "c" : "{x} is odd and {y} is even", "d" : "{x} is even and {y} is even" } """)
class CustomModelAdmin(admin.ModelAdmin): formfield_overrides = { DummyJsonField: { 'widget': JSONEditor() }, DummyHtmlField: { 'widget': CodeMirrorEditor(options={ 'mode': 'xml', 'lineNumbers': True, 'lineWrapping': True }) } }
class Meta: widgets = { 'extra_configuration': JSONEditor(), 'user_password': PasswordWidget(), }
class Meta: widgets = { 'config': JSONEditor(), }
class Meta: widgets = { 'report': JSONEditor(), }
class Meta: widgets = { 'attributes': JSONEditor(), 'geolocations': JSONEditor(), 'options': JSONEditor(), }
class Meta: widgets = { 'context': JSONEditor(), }
class Meta: widgets = { 'extra': JSONEditor(), }
class Meta: widgets = { 'options': JSONEditor(), 'geolocations': JSONEditor(), 'password': PasswordWidget(), }
class Meta: widgets = { 'interface_parameters': JSONEditor(), }
class Meta: widgets = { 'arguments': JSONEditor(), }