Changes between Version 1 and Version 2 of Ticket #26131


Ignore:
Timestamp:
Jan 24, 2016, 9:35:11 AM (9 years ago)
Author:
stiffupperlip
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26131 – Description

    v1 v2  
    11In Django 1.8.8 when I create a model class like below, choices are not enforced when creating an instance of the model class:
    22
    3     class HTTPMethod(models.Model):
    4         HTTP_METHODS = [(_, _) for _ in ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace', 'connect']]
     3{{{
     4class HTTPMethod(models.Model):
     5    HTTP_METHODS = [(_, _) for _ in ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace', 'connect']]
    56
    6         id = models.AutoField(primary_key=True)
    7         name = models.CharField(choices=HTTP_METHODS, unique=True, max_length=255)
     7    id = models.AutoField(primary_key=True)
     8    name = models.CharField(choices=HTTP_METHODS, unique=True, max_length=255)
    89
    910
    10     h = HTTPMethod(name='something invalid')
    11     h.save()
     11h = HTTPMethod(name='something invalid')
     12h.save()
     13}}}
    1214
    13 No errors are raised.
     15No errors are raised and invalid data is stored in the model.
    1416
    1517Python 2.7.6 on Ubuntu 14.04
Back to Top