How to use the puput.models.BlogPage.objects.first function in puput

To help you get started, we’ve selected a few puput examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github APSL / puput / puput / feeds.py View on Github external
def __call__(self, request, *args, **kwargs):
        if request.resolver_match.url_name == 'blog_page_feed_slug':
            self.blog_page = BlogPage.extra.get_by_path(kwargs['blog_path'])
            if not self.blog_page:
                raise http.Http404
        else:
            self.blog_page = BlogPage.objects.first()
        self.request = request
        return super(BlogPageFeed, self).__call__(request, *args, **kwargs)
github climu / openstudyroom / fancysearch / views.py View on Github external
def blog_search(request):
    query = request.GET.get('query', None)
    if query is not None:
        blog_page = BlogPage.objects.first()
        entries = blog_page.get_entries().search(query)[:5]
        results = []
        for entry in entries:
            results.append({
                'title': entry.title,
                'url': entry.get_url(request)
            })
        data = json.dumps(results)
    else:
        data = 'fail'
    mimetype = 'application/json'
    return HttpResponse(data, mimetype)