June 2018
Beginner
508 pages
13h 8m
English
This view is much more interesting than the previous one:
# entries/views.pyclass EntryListView(TemplateView): template_name = 'entries/list.html' @method_decorator( login_required(login_url=reverse_lazy('login'))) def get(self, request, *args, **kwargs): context = self.get_context_data(**kwargs) entries = Entry.objects.filter( user=request.user).order_by('-date_added') matches = (self._parse_entry(entry) for entry in entries) context['entries'] = list(zip(entries, matches)) return self.render_to_response(context) def _parse_entry(self, entry): match = re.search(entry.pattern, entry.test_string) if match is not None: return ( match.group(), match.groups() or None, match.groupdict() or None ) return None
First of all, we ...
Read now
Unlock full access