Changes between Version 1 and Version 2 of Ticket #26131
- Timestamp:
- Jan 24, 2016, 9:35:11 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #26131 – Description
v1 v2 1 1 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: 2 2 3 class HTTPMethod(models.Model): 4 HTTP_METHODS = [(_, _) for _ in ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace', 'connect']] 3 {{{ 4 class HTTPMethod(models.Model): 5 HTTP_METHODS = [(_, _) for _ in ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace', 'connect']] 5 6 6 7 7 id = models.AutoField(primary_key=True) 8 name = models.CharField(choices=HTTP_METHODS, unique=True, max_length=255) 8 9 9 10 10 h = HTTPMethod(name='something invalid') 11 h.save() 11 h = HTTPMethod(name='something invalid') 12 h.save() 13 }}} 12 14 13 No errors are raised .15 No errors are raised and invalid data is stored in the model. 14 16 15 17 Python 2.7.6 on Ubuntu 14.04