Opened 10 years ago
Last modified 10 years ago
#26131 closed Bug
model field choices are not enforced — at Version 1
| Reported by: | stiffupperlip | Owned by: | nobody | 
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.8 | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description (last modified by )
In Django 1.8.8 when I create a model class like below, choices are not enforced when creating an instance of the model class:
class HTTPMethod(models.Model):
HTTP_METHODS = [(_, _) for _ in ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace', 'connect']]
id = models.AutoField(primary_key=True)
name = models.CharField(choices=HTTP_METHODS, unique=True, max_length=255)
h = HTTPMethod(name='something invalid')
h.save()
No errors are raised.
Python 2.7.6 on Ubuntu 14.04