diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bbe1bd02f201ab915520d5125316084bed48ad16..58d3e5c77576466992154fde308311b4a171da5a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -114,7 +114,7 @@ black:
   before_script:
     - pip install black
   script:
-    - black --exclude "/(\.git|\.hg|\.mypy_cache|\.tox|\.venv|_build|buck-out|build|dist|migrations)/" --check --diff api/
+    - black --check --diff api/
 
 flake8:
   image: python:3.6
diff --git a/pyproject.toml b/pyproject.toml
index 68682d243c231a3fed2f52e5948b9507df9bd42f..21dd7c106dc42ca536762624c3b387610de3824b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,3 +41,6 @@
         directory = "misc"
         name = "Other"
         showcontent = true
+
+[tool.black]
+    exclude = "(.git|.hg|.mypy_cache|.tox|.venv|_build|buck-out|build|dist|migrations)"