Skip to content

Commit

Permalink
docs: small link fixes, corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
hodossy committed Dec 23, 2020
1 parent 1414f1d commit 8ab4b83
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Install using `pip`,
pip install django-nlf
```

And add :code:`django_nlf` to your :code:`INSTALLED_APPS`.
And add `django_nlf` to your `INSTALLED_APPS`.

```
INSTALLED_APPS = [
Expand All @@ -34,12 +34,12 @@ from .models import Article

nl_filter = DjangoNLFilter()
qs = Article.objects.all()
q = 'author.username is john or title contains news'
q = "author.username is john or title contains news"
# equivalent to Article.objects.filter(Q(author__username="user") | Q(title__icontains="news"))
articles = nl_filter.filter(qs, q)

# Nested logical operators are also supported:
q = 'author.username is john and (title contains news or created_at <= 2020-06-05)'
q = "author.username is john and (title contains news or created_at <= 2020-06-05)"
# equivalent to
# Article.objects.filter(
# Q(author__username="user") & (Q(title__icontains="news") | Q(created_at__lte="2020-06-05"))
Expand All @@ -51,11 +51,11 @@ articles = nl_filter.filter(qs, q)

You just need to simply add the natural language filter backend to your filter backends list.

```
```python
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': (
"DEFAULT_FILTER_BACKENDS": (
...
'django_nlf.rest_framework.DjangoNLFilterBackend',
"django_nlf.rest_framework.DjangoNLFilterBackend",
),
}
```
4 changes: 0 additions & 4 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,3 @@ NLF_QUERY_PARAM
Default: ``"q"``

This applies to the Django RESTFramework Backend. This parameter is used for extracting the filter expression from the ``GET`` query parameters.


"PATH_SEPARATOR": ".",
"QUERY_PARAM": "q",
11 changes: 11 additions & 0 deletions docs/customizations/field_name_conversion.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Converting field names
======================

You may not like the snake case convention widely used in Python to be used in the filtering expressions your user write. Therefore you can use one of the built in case coverters or write your own.

Built in converters
*******************

.. autofunction:: django_nlf.utils.camel_to_snake_case


Custom converter
****************

To support automatic case conversion, a custom implementation can be provided.

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion docs/customizations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Customization
.. toctree::
:maxdepth: 1

custom_functions.rst
field_name_conversion.rst
custom_functions.rst
4 changes: 2 additions & 2 deletions docs/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ All development dependencies are listed in :code:`dev_requirements.txt`.
A :code:`Makefile` is available with the most common operations that are need to be run. The following targets are available:

- :code:`make lint`: Runs [black](https://black.readthedocs.io/en/stable/) in check mode and [pylint](http://pylint.pycqa.org/)
- :code:`make format`: Runs [black](https://black.readthedocs.io/en/stable/) and formats each file
- :code:`make lint`: Runs `black <https://black.readthedocs.io/en/stable/>`_ in check mode and `pylint <http://pylint.pycqa.org/>`_
- :code:`make format`: Runs `black <https://black.readthedocs.io/en/stable/>`_ and formats each file
- :code:`make test`: Runs the test suite
- :code:`make coverage`: Runs the test suite and measures coverage
- :code:`make docs`: Builds the documentation
Expand Down
8 changes: 4 additions & 4 deletions docs/language/lookups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ Supported Lookups

The lookups are all case insensitive.

.. note::

Custom lookups are not supported currently.

Equals
******

Expand Down Expand Up @@ -38,3 +34,7 @@ Lower than (or equal)
***********************

Can be expressed as :code:`<` and :code:`<=`, and means a comparison against the given value.

.. note::

Custom lookups are not supported currently.
2 changes: 1 addition & 1 deletion docs/language/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Can be expressed as :code:`or`.
Not
***

Can be expressed as :code:`not` in front of *functions*, *expressions* or group of *expressions*.
Can be expressed as :code:`not` in front of *functions* and group of *expressions*. *Expressions* can be negated by negating the *lookup* (e.g. :code:`is` -> :code:`is not`).

Groups
******
Expand Down

0 comments on commit 8ab4b83

Please sign in to comment.