def update(self): settings = DeliciousSettings.get() form = DeliciousSettingsForm(instance=settings) if self.request.method == 'POST': if self.request.POST.get("action") == "save": form = DeliciousSettingsForm(data=self.request.POST, instance=settings) if form.is_valid(): form.save() else: delicious.posts_all(refresh=True) self.context.update(locals())
def links(request): all_posts = delicious.posts_all() by_tag = defaultdict(list) for post in all_posts: for tag in post['tags']: by_tag[tag].append(post) tags = [{'name':tag,'posts':posts} for tag, posts in by_tag.iteritems()] return 'links.html', {'tags':tags}