Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialigsm '
10,440 PointsWas a trailing comma forgotten in index setting?
Kenneth Love, I read in peewee docs that we need to add a trailing comma if tuple of indexes contains only one item. I believe we forgot that in the video or was that intentional? Anyway, what's the use of that ?
indexes = (
(('from_user', 'to_user'), True),
)
1 Answer
Dave Leigh
8,640 PointsI noticed in the video for this stage that Kenneth Love was getting the same error I was when I tried to run the app after making the changes:
File "app.py", line 157, in <module>
models.initialize()
File "/home/treehouse/workspace/models.py", line 86, in initialize
DATABASE.create_tables([User, Post, Relationship], safe=True)
File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/peewee.py", line 2863, in create_tables
create_model_tables(models, fail_silently=safe)
File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/peewee.py", line 3871, in create_model_tables
m.create_table(**create_table_kwargs)
File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/peewee.py", line 3628, in create_table
cls._create_indexes()
File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/peewee.py", line 3652, in _create_indexes
db.create_index(cls, fields, unique)
File "/usr/local/pyenv/versions/3.4.1/lib/python3.4/site-packages/peewee.py", line 2869, in create_index
'or tuple: "%s"' % fields)
ValueError: Fields passed to "create_index" must be a list or tuple: "from_user"
This error appears to have been resolved by the start of the "Follow and Unfollow Buttons" video. After adding the trailing comma as Igor suggested, the error disappeared.
Thanks!
Alx Ki
Python Web Development Techdegree Graduate 14,822 PointsAlx Ki
Python Web Development Techdegree Graduate 14,822 PointsOr you can make it a list, I guess.