(use traductor si necesita)

I hope I understand your question correctly.

When in Django 1.8 or 1.9+ you can just do
self.fields['destination'].disabled = True

in lower versions you should add
self.fields['destination'].widget.attrs['disabled'] = True
at the end of your __init__(..).


W dniu wtorek, 18 września 2018 20:58:26 UTC+2 użytkownik nelson fernando 
garcia gomez napisał:
>
> Hola estoy tratando en mi formulario (formsModel) implementar el atributo 
> de *readonly*  a una foreignkey (ModelChoiceField)
> pero no es posible alguna ayuda por favor GRACIAS así lo estoy haciendo: 
> class CostoForm(forms.ModelForm):
>
> """
> Edicion de Costos con formset.
> """
> class Meta:
>     model = Costo
>     exclude = ('user', )
>
> def __init__(self, *args, **kwargs):
>     super(CostoForm, self).__init__(*args, **kwargs)
>     self.helper = FormHelper()
>     self.helper.form_tag = False
>     self.helper.form_action = ''
>     self.helper.form_class = 'form-inline'
>     self.helper.template = 'crispy_template/table_inline_formset.html'
>     self.helper.layout = Layout(
>         Field('DELETE', css_class='btn btn-primary')
>     )
>     self.helper.add_input(Submit('submit', _('Aceptar')))
>     self.fields['destination'].widget.attrs['readonly'] = True
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5adc1b66-747a-4678-afa3-55c2a8fa53e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to