diff --git a/docs/filtering.rst b/docs/filtering.rst index 95576a091..85d047b35 100644 --- a/docs/filtering.rst +++ b/docs/filtering.rst @@ -9,12 +9,12 @@ for details on the format for ``filter_fields``. This filtering is automatically available when implementing a ``relay.Node``. Additionally ``django-filter`` is an optional dependency of Graphene. -You will need to install it manually, which can be done as follows: +You can install it as follows: .. code:: bash - # You'll need to install django-filter - pip install django-filter>=2 + # Install graphene-django with django-filter support. + pip install "graphene-django[filter]" After installing ``django-filter`` you'll need to add the application in the ``settings.py`` file: diff --git a/docs/tutorial-relay.rst b/docs/tutorial-relay.rst index 8ea69da28..3559b1e4a 100644 --- a/docs/tutorial-relay.rst +++ b/docs/tutorial-relay.rst @@ -32,9 +32,8 @@ We will setup the project, create the following: virtualenv env source env/bin/activate # On Windows use `env\Scripts\activate` - # Install Django and Graphene with Django support - pip install django - pip install graphene_django + # Install Django and Graphene with django-filter support + pip install django "graphene_django[filter]" # Set up a new project with a single application django-admin.py startproject cookbook . # Note the trailing '.' character @@ -165,11 +164,7 @@ The filtering functionality is provided by documentation `__ for details on the format for ``filter_fields``. While optional, this tutorial makes use of this functionality so you will need to install -``django-filter`` for this tutorial to work: - -.. code:: bash - - pip install django-filter +``django-filter`` for this tutorial to work. Note that the above ``Query`` class is marked as 'abstract'. This is because we will now create a project-level query which will combine all diff --git a/graphene_django/filter/__init__.py b/graphene_django/filter/__init__.py index e4dbc0651..3fdfdac5f 100644 --- a/graphene_django/filter/__init__.py +++ b/graphene_django/filter/__init__.py @@ -5,7 +5,7 @@ if not DJANGO_FILTER_INSTALLED: warnings.warn( "Use of django filtering requires the django-filter package " - "be installed. You can do so using `pip install django-filter`", + "be installed. You can do so using `pip install 'graphene-django[filter]'`", ImportWarning, ) else: diff --git a/setup.py b/setup.py index 6fc0a1816..6b73f3ce1 100644 --- a/setup.py +++ b/setup.py @@ -10,19 +10,23 @@ ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1)) ) -rest_framework_require = ["djangorestframework>=3.6.3"] +filter_require = ["django-filter>=22.1"] +rest_framework_require = ["djangorestframework>=3.6.3"] -tests_require = [ - "pytest>=7.3.1", - "pytest-cov", - "pytest-random-order", - "coveralls", - "mock", - "pytz", - "django-filter>=22.1", - "pytest-django>=4.5.2", -] + rest_framework_require +tests_require = ( + [ + "pytest>=7.3.1", + "pytest-cov", + "pytest-random-order", + "coveralls", + "mock", + "pytz", + "pytest-django>=4.5.2", + ] + + filter_require + + rest_framework_require +) dev_requires = [ @@ -73,6 +77,7 @@ rest_framework_require=rest_framework_require, extras_require={ "test": tests_require, + "filter": filter_require, "rest_framework": rest_framework_require, "dev": dev_requires, },