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 trial

Python Flask REST API Resourceful Blueprints Beyond GET and POST

Stephen Falck
Stephen Falck
7,558 Points

I have a question regarding the put method, which i am using on an api im creating myself

My put method is set up exactly the same with the args being parsed, a query being created using those args and related to an entry with a specific id and i keep getting this response:

TypeError: get_sort_key() missing 1 required positional argument: 'ctx'

any help?

Stephen Falck
Stephen Falck
7,558 Points
def put(self, id):
        args = self.reqparse.parse_args()
        query = BlogPostModel.Post.update(**args).where(BlogPostModel.Post.id==id)
        query.execute()
        return (BlogPostModel.Post.get(BlogPostModel.Post.id==id), 200,
                {'Location': url_for('views.BlogPostView.post', id=id)})

1 Answer

My guess is that you're not passing in ctx to that method. Can't really tell without looking at your code, though. Please paste it in, in a code block (surrounded by 3 back tics ```).