Run blacken docs on docs folder

This commit is contained in:
Bruno Alla 2025-10-14 08:16:11 +02:00
parent 9b27ee7126
commit 3f625e30ba
3 changed files with 16 additions and 19 deletions

View File

@ -67,10 +67,11 @@ Install using `pip`...
pip install djangorestframework
Add `'rest_framework'` to your `INSTALLED_APPS` setting.
```python
INSTALLED_APPS = [
...
'rest_framework',
# ...
"rest_framework",
]
```
@ -99,7 +100,7 @@ from rest_framework import routers, serializers, viewsets
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'username', 'email', 'is_staff']
fields = ["url", "username", "email", "is_staff"]
# ViewSets define the view behavior.
@ -110,13 +111,13 @@ class UserViewSet(viewsets.ModelViewSet):
# Routers provide a way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r"users", UserViewSet)
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path("", include(router.urls)),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]
```
@ -126,15 +127,15 @@ Add the following to your `settings.py` module:
```python
INSTALLED_APPS = [
... # Make sure to include the default installed apps here.
'rest_framework',
# ... make sure to include the default installed apps here.
"rest_framework",
]
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly",
]
}
```

View File

@ -231,7 +231,7 @@ Using the example from the previous section:
Alternatively, you can use the `url_name` attribute set by the `@action` decorator.
```pycon
>>> view.reverse_action(view.set_password.url_name, args=['1'])
>>> view.reverse_action(view.set_password.url_name, args=["1"])
'http://localhost:8000/api/users/1/set_password'
```

View File

@ -50,11 +50,9 @@ class DocStringExampleListView(APIView):
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
def get(self, request, *args, **kwargs):
...
def get(self, request, *args, **kwargs): ...
def post(self, request, *args, **kwargs):
...
def post(self, request, *args, **kwargs): ...
```
## Validator / Default Context
@ -76,8 +74,7 @@ Validator implementations will look like this:
class CustomValidator:
requires_context = True
def __call__(self, value, serializer_field):
...
def __call__(self, value, serializer_field): ...
```
Default implementations will look like this:
@ -86,8 +83,7 @@ Default implementations will look like this:
class CustomDefault:
requires_context = True
def __call__(self, serializer_field):
...
def __call__(self, serializer_field): ...
```
---