How to use the djangoql.exceptions.DjangoQLError function in djangoql

To help you get started, we’ve selected a few djangoql 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 ivelum / djangoql / test_project / core / views.py View on Github external
def completion_demo(request):
    q = request.GET.get('q', '')
    error = ''
    query = User.objects.all().order_by('username')
    if q:
        try:
            query = apply_search(query, q, schema=UserQLSchema)
        except DjangoQLError as e:
            query = query.none()
            error = str(e)
    return render(request, 'completion_demo.html', context={
        'q': q,
        'error': error,
        'search_results': query,
        'introspections': json.dumps(UserQLSchema(query.model).as_dict()),
    })
github ivelum / djangoql / djangoql / exceptions.py View on Github external
self.line = line
        self.column = column
        super(DjangoQLError, self).__init__(message)

    def __str__(self):
        message = super(DjangoQLError, self).__str__()
        if self.line:
            position_info = 'Line %s' % self.line
            if self.column:
                position_info += ', col %s' % self.column
            return '%s: %s' % (position_info, message)
        else:
            return message


class DjangoQLSyntaxError(DjangoQLError):
    pass


class DjangoQLLexerError(DjangoQLSyntaxError):
    pass


class DjangoQLParserError(DjangoQLSyntaxError):
    pass


class DjangoQLSchemaError(DjangoQLError):
    pass
github ivelum / djangoql / djangoql / admin.py View on Github external
not self.djangoql_search_enabled(request)
        ):
            return super(DjangoQLSearchMixin, self).get_search_results(
                request=request,
                queryset=queryset,
                search_term=search_term,
            )
        use_distinct = False
        if not search_term:
            return queryset, use_distinct
        try:
            return (
                apply_search(queryset, search_term, self.djangoql_schema),
                use_distinct,
            )
        except (DjangoQLError, ValueError, FieldError, ValidationError) as e:
            msg = self.djangoql_error_message(e)
            messages.add_message(request, messages.WARNING, msg)
            return queryset.none(), use_distinct
github ivelum / djangoql / djangoql / exceptions.py View on Github external
def __str__(self):
        message = super(DjangoQLError, self).__str__()
        if self.line:
            position_info = 'Line %s' % self.line
            if self.column:
                position_info += ', col %s' % self.column
            return '%s: %s' % (position_info, message)
        else:
            return message
github kiwicom / the-zoo / zoo / libraries / views.py View on Github external
| Q(impact__icontains=queryterm)
                )

            elif re.match(URL_QUERY_PATTERN, queryterm):
                queryset = queryset.filter(
                    Q(docs_url__icontains=queryterm)
                    | Q(library_url__icontains=queryterm)
                    | Q(health_check_url__icontains=queryterm)
                )

            else:
                try:
                    queryset = apply_search(
                        queryset, queryterm, models.LibrarySQLSchema
                    )
                except DjangoQLError:
                    log.exception("libraries.query_error", queryterm=queryterm)
                    return self.model.objects.none()

        return queryset.order_by("name")
github ivelum / djangoql / djangoql / exceptions.py View on Github external
return message


class DjangoQLSyntaxError(DjangoQLError):
    pass


class DjangoQLLexerError(DjangoQLSyntaxError):
    pass


class DjangoQLParserError(DjangoQLSyntaxError):
    pass


class DjangoQLSchemaError(DjangoQLError):
    pass
github kiwicom / the-zoo / zoo / services / views.py View on Github external
| Q(owner__icontains=queryterm)
                    | Q(status__icontains=queryterm)
                    | Q(impact__icontains=queryterm)
                )

            elif re.match(URL_QUERY_PATTERN, queryterm):
                queryset = queryset.filter(
                    Q(docs_url__icontains=queryterm)
                    | Q(environment__health_check_url__icontains=queryterm)
                    | Q(environment__service_urls__icontains=queryterm)
                )

            else:
                try:
                    queryset = apply_search(queryset, queryterm, models.ServiceQLSchema)
                except DjangoQLError:
                    log.exception("services.query_error", queryterm=queryterm)
                    return self.model.objects.none()

        return queryset.order_by("name")