就像在标题中一样,我想将呈现在表单上的字段交换。例如我有以下模型:
models.py
class Project(models.Model):
name = models.TextField(max_length=200)
finished = models.BoolenField(default=False)
admin.py
class ProjectAdmin(admin.ModelAdmin):
def get_form(self, request, obj=None, **kwargs):
if request.user.is_superuser:
#here change the name field form TextField
#to a disabled TextField or to other Field defined by me
self.form['name']['widget] = MySuperDuperWidgetField() #or smth like that
可能吗?