Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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)
        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 ```).