I have a model:
class myLimit(models.Model):
limit = models.PositiveSmallIntegerField(help_text="The upper limit of the number of points that can be used.")
TYPES_OF_LIMITS = [('perday','Limit Per Day'),('lifetime', 'Lifetime Limit'),('peruser', 'Per User'),]
limit_type = models.CharField(choices=TYPES_OF_LIMITS, max_length=20, default='lifetime')
...
I want to know how to disable (or make it read-only) the "peruser" ("Per User") choice/option. The current myLimit
acts as a base model for an extended model which sets the default of limit_type
to "peruser" and makes the entire thing read-only my using admin model's exclude = ('limit_type',)
.
I set the default in the save()
method of the extended model just before calling the super method. The main question remains: How to make a few choices read-only? I have read tutorials on making the entire field read-only, hiding it, and others but haven't figured out a way to make "only some choices" read-only.