Changes between Initial Version and Version 2 of Ticket #21236
- Timestamp:
- Oct 6, 2013, 7:24:13 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #21236 – Description
initial v2 1 1 This occurs when trying to apply a migration that contains a single modification: the application of a unique_together constraint. full traceback at the end, but the problem seems to come around here: 2 2 3 {{{ 3 4 self.create_model(temp_model) 4 5 File "/workspace/virtualenv/lib/python3.3/site-packages/django/db/backends/schema.py", line 225, in create_model … … 7 8 % (self.object_name, name)) 8 9 django.db.models.fields.FieldDoesNotExist: Item has no field named 'l' 10 }}} 9 11 10 Context: this is a model whose unique_together constraint is on its only two fields, which in this case are called 11 "list" and "item": 12 12 Context: this is a model whose unique_together constraint is on its only two fields, which in this case are called `list` and `item`: 13 {{{#!python 13 14 migrations.AlterUniqueTogether( 14 15 unique_together = set(['text', 'list']), 15 16 name = 'item', 16 17 ), 17 18 }}} 18 19 19 20 I did a little digging. Inside the 'schema.py', in the `create_model` function, a little debug print like this: 20 21 21 print('unique_together', model._meta.unique_together) 22 {{{#!python 23 print('unique_together', model._meta.unique_together) 24 }}} 22 25 23 26 gives 24 27 28 {{{#!python 25 29 unique_together [('l', 'i', 's', 't'), ('t', 'e', 'x', 't')] 30 }}} 26 31 27 32 Looks like some list comprehension somewhere has gone wrong? … … 37 42 then just cd into myproject, run python manage.py syncdb, and you should get: 38 43 44 {{{ 39 45 $ python manage.py syncdb 40 46 Operations to perform: … … 84 90 % (self.object_name, name)) 85 91 django.db.models.fields.FieldDoesNotExist: Item has no field named 't' 86 92 }}} 87 93 88 94 Full trac 95 {{{ 89 96 /home/harry/Dropbox/book/source/chapter_09/virtualenv/lib/python3.3/site-packages/django/db/backends/schema.py 90 97 … … 136 143 % (self.object_name, name)) 137 144 django.db.models.fields.FieldDoesNotExist: Item has no field named 't' 145 }}}