On 24 Jun 2020, at 23:03, Chetan Ganji wrote:

Try this one
https://docs.djangoproject.com/en/3.0/ref/forms/fields/#disabled

Ok, well that's a little help, because I can disable the input:

status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect(attrs={'disabled': True}))

And I can put a "useless" if statement around it to get different outputs:

    if 1 == 1 :
status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect(attrs={'disabled': True}))
    else :
status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect(attrs={}))

But, I can't work out how to get a meaningful if comparison, like:

    if Profile.status == 'personal' :
status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect(attrs={'disabled': True}))
    else :
status = forms.ChoiceField(choices=Profile.status_choices, widget=forms.RadioSelect(attrs={}))

Any string I put in 'personal' always returns false, so I can switch the output with "==" or "!=", but I can't assess the output in reference to what I expect to be in the database fields. Django accepts "Profile.status" as a relevant property, so I am a bit lost as to how to continue, or debug this. If I try "print(locals()) or print(Profile.status) I get no output in the terminal.


-- Clive

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/940FE834-1B08-4542-934C-808668E99B35%40indx.co.uk.

Reply via email to