Changes between Initial Version and Version 1 of Ticket #24539
- Timestamp:
- Mar 26, 2015, 12:42:10 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #24539 – Description
initial v1 1 1 I have this model {{{Product}}}, child of an abstract model which defines a {{{created}}} field with {{{auto_now_add}}} set. All the CRUD works just fine so far. 2 2 3 The problem happens when I add a custom primary key to {{{Product}}}: If I try to '''create''' a {{{Product}}} object '''through the admin'''giving the {{{reference}}} field a repeated value, expecting to see a nice validation error message saying that another object with that reference already exists, I get an {{{IntegrityError}}} stating that the {{{created}}} field cannot be {{{NULL}}} (traceback attached) -- nothing even about the custom primary key.3 The problem happens when I add a custom primary key to {{{Product}}}: If I try to '''create''' a {{{Product}}} object through the admin giving the {{{reference}}} field a repeated value, expecting to see a nice validation error message saying that another object with that reference already exists, I get an {{{IntegrityError}}} stating that the {{{created}}} field cannot be {{{NULL}}} (traceback attached) -- nothing even about the custom primary key. 4 4 5 Note: I noticed the exception is raised from an {{{UPDATE}}} query, which is really odd since I'm posting data from the admin add view. 5 Notes: 6 7 - I noticed the exception is raised from an {{{UPDATE}}} query, which is really odd since I'm posting data from the admin add view. 8 - {{{Product(reference=x).save()}}} raises the same exception, but {{{Product.objects.create(reference=x}}} raises the expected exception ({{{IntegrityError}}} about the PK's UNIQUE constraint), which proves that it's not a problem on the admin.