Reputation: 993
I know I can explicity set the field option editable False on a value. For example
name = models.CharField(editable=False)
But is it possible to change the default value of a field option. So for, example editable would be False by default and I would have to explicitly set it True to make the field editable?
Upvotes: 0
Views: 387
Reputation: 94222
Create a new Field class called DefaultNotEditableCharField which inherits everything from CharField but overrides editable=False.
Personally, I'd say suck it up and type 'editable=False' everywhere you want editable to be False, since that's the documented way to do it and it'll be what people expect.
Upvotes: 1
Reputation: 34563
One approach would be to make the field editable by default and exclude the field from the form class you'll be using to edit the model, or make the field read-only at the form level.
Upvotes: 0