I have such admin code:

class SomeModelAdminForm(forms.ModelForm):
    custom_field1 = forms.CharField(...)
    custom_field2 = forms.IntegerField(...)


class SomeModelAdmin(admin.ModelAdmin):

    fields = ...
    readonly_fields = ...

    form = SomeModelAdminForm

    def get_readonly_fields(self, request, obj=None):
        ro = super(ProductAdmin, self).get_readonly_fields(request, obj)
        if obj:
            if obj.some_field is None:
                ro.append('custom_field1')
            else:
                ro.append('custom_field2')
        return ro

When I access the change form page of model, I am getting error

Unable to lookup 'custom_field1' on SomeModel or SomeModelAdmin or SomeModelForm


Is it a bug or I expect wrong behaviour from this code?

-- 
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/b427f377-5c3e-4a8a-a5e5-aec3168e3b0fo%40googlegroups.com.

Reply via email to