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 Django ORM Total Control Mind your Ps and Qs

How search is working?

I have not seen the search function in any of the previous videos , and what does " term = request.GET.get('q') " do.

1 Answer

Quite a late answer, but maybe this will help someone:

When there is a form with method="GET all input fields will be added to URL of the submit request. So <input type="search" name="q"> means "q=Android" will be added to the next URL.

When handling the request request.GET returns a dictionary of all the URL parameters of GET request: so /courses/search/?q=Android will return {'q':['Android']}`

and .get('q') gets the value for the 'q'.