Sometimes something that is supposed to be very simple turns out to two minutes of work, IF AND ONLY IF you already know [blah blah blah technical thing]A big problem with using a software platform as a starting point for development is it locks you into its way of doing things, including using all of the platforms it in turn is built on. However, sometimes it just works fine (or, I suppose, it's possible that I learning something), and something that should take two minutes not only takes only two minutes, but also saves you from something else that could have taken hours.
Example: In Whatnext, you can filter your task list by a word in the task title or notes. Here's an example, all of my tasks regarding "windows":
%20, for obvious reasons (that was sarcasm). I anticipated a headache around fixing my code to handle spaces properly. First, I tried filtering by "wash windows" and was mildly stunned that it worked perfectly:
def get_context_data(self, **kwargs): context = super(TaskQueryMixin, self).get_context_data(**kwargs) state_params=QueryDict(query_string=None, mutable=True) state_params.setlist('tags',self.request.GET.getlist('tags')) state_params.__setitem__('show_closed', self.request.GET.get('show_closed', '')) state_params.__setitem__('show_snoozed', self.request.GET.get('show_snoozed', '')) state_params.__setitem__('page', self.request.GET.get('page', '')) context['state_url_fragment']=state_params.urlencode() return context
When I added this new code in the middle:
state_params.__setitem__('name', self.request.GET.get('name', '')) state_params.__setitem__('notes', self.request.GET.get('notes', ''))
it all got a free ride thanks to the
.urlencode()function at the end, and it changes "wash windows" into
%20because reasons, I guess), and then changes it back at the appropriate time, and it all works fine. I'm nervous to search for a
+only to have it fail and break the fragile feeling that I picked a decent platform.
+works fine. It gets encoded to