Skip to content

Commit 1b6b760

Browse files
committed
Enforce readonly name field for existing Test_Type instances in form
1 parent 5057b4b commit 1b6b760

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

dojo/forms.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ class Meta:
324324
model = Test_Type
325325
exclude = ["dynamically_generated"]
326326

327+
def __init__(self, *args, **kwargs):
328+
super().__init__(*args, **kwargs)
329+
330+
if self.instance.pk:
331+
self.fields["name"].widget.attrs["readonly"] = True
332+
333+
def clean_name(self):
334+
if self.instance.pk:
335+
return self.instance.name
336+
return self.cleaned_data["name"]
337+
327338

328339
class Development_EnvironmentForm(forms.ModelForm):
329340
class Meta:

0 commit comments

Comments
 (0)