You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📦 Package located at https://pypi.org/project/django-fbv/
12
+
## Why? 🤔
13
13
14
-
## Features
14
+
The Django community has two ways to write views: [class-based](https://docs.djangoproject.com/en/stable/topics/class-based-views/) and [function-based](https://docs.djangoproject.com/en/stable/topics/http/views/). One benefit of function-based views is that the input of a `HttpRequest` and the `HttpResponse` output is explicit.
15
15
16
-
## Features
16
+
`django-fbv` reduces the boilerplate code required when using function-based views. It also leverages _locality of behavior_ -- the name of the template is clearly associated to the view, instead of being part of the return statement.
If you want a more detailed critique of class-based views, I recommend reading [Django Views the Right Way](https://spookylukey.github.io/django-views-the-right-way/).
41
+
```
42
+
43
+
## Installation ⚙️
44
+
45
+
`pip install django-fbv` OR `uv add django-fbv`
46
+
47
+
The [decorators](decorators.md) and [views](views.md) can be used by just importing them. The middleware [needs to be installed](https://django-fbv.adamghill.com/en/latest/middleware/#installation).
48
+
49
+
## Features 🤩
17
50
18
51
### Decorators
19
52
20
53
-[`fbv.decorators.render_html`](https://django-fbv.adamghill.com/en/latest/decorators/#render-html): renders a view as HTML with the specified template
21
54
-[`fbv.decorators.render_view`](https://django-fbv.adamghill.com/en/latest/decorators/#render-view): renders a view as a content type with the specified template
renders dictionaries, Django Models, or Django QuerySets as a JSON response
56
+
renders dictionaries, Django `Model`, or Django `QuerySet` as a `JSON` response
24
57
25
58
### Views
26
59
@@ -34,4 +67,7 @@ renders dictionaries, Django Models, or Django QuerySets as a JSON response
34
67
35
68
-[`fbv.middleware.RequestMethodMiddleware`](https://django-fbv.adamghill.com/en/latest/middleware/): adds a boolean property to the `request` for the current request's HTTP method
36
69
37
-
Read all of the documentation at https://django-fbv.adamghill.com/.
70
+
## Prior art 🖼️
71
+
72
+
- The `render_view` decorator was forked from `render_to` in https://github.com/skorokithakis/django-annoying.
73
+
- The `file`, `favicon_file` and `favicon_emoji` code is from https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/.
Copy file name to clipboardExpand all lines: docs/source/index.md
+36-10Lines changed: 36 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,51 @@
2
2
3
3
`django-fbv` includes utilities to make function-based views cleaner, more efficient, and better tasting. 💥
4
4
5
-
## Why?
5
+
## Why? 🤔
6
6
7
-
The Django community has two ways to build views: class-based and function-based. This library is intended to solve for some of the annoyances of function-based views.
7
+
The Django community has two ways to write views: [class-based](https://docs.djangoproject.com/en/stable/topics/class-based-views/) and [function-based](https://docs.djangoproject.com/en/stable/topics/http/views/). One benefit of function-based views is that the input of a `HttpRequest` and the `HttpResponse` output is explicit.
8
8
9
-
If you want to read a more detailed critique of class-based views, https://spookylukey.github.io/django-views-the-right-way/is excellent.
9
+
`django-fbv` reduces the boilerplate code required when using function-based views. It also leverages _locality of behavior_ -- the name of the template is clearly associated to the view, instead of being part of the return statement.
If you want a more detailed critique of class-based views, I recommend reading [Django Views the Right Way](https://spookylukey.github.io/django-views-the-right-way/).
34
+
```
35
+
36
+
## Installation ⚙️
12
37
13
38
`pip install django-fbv` OR `uv add django-fbv`
14
39
15
-
The [decorators](decorators.md) and [views](views.md) can be used by just importing them. The middleware [needs to be installed](middleware.md#installation).
40
+
The [decorators](decorators.md) and [views](views.md) can be used by just importing them. The middleware [needs to be installed](https://django-fbv.adamghill.com/en/latest/middleware/#installation).
16
41
17
-
## Features
42
+
## Features 🤩
18
43
19
44
### Decorators
20
45
21
46
-[`fbv.decorators.render_html`](https://django-fbv.adamghill.com/en/latest/decorators/#render-html): renders a view as HTML with the specified template
22
47
-[`fbv.decorators.render_view`](https://django-fbv.adamghill.com/en/latest/decorators/#render-view): renders a view as a content type with the specified template
renders dictionaries, Django Models, or Django QuerySets as a JSON response
49
+
renders dictionaries, Django `Model`, or Django `QuerySet` as a `JSON` response
25
50
26
51
### Views
27
52
@@ -35,10 +60,11 @@ renders dictionaries, Django Models, or Django QuerySets as a JSON response
35
60
36
61
-[`fbv.middleware.RequestMethodMiddleware`](https://django-fbv.adamghill.com/en/latest/middleware/): adds a boolean property to the `request` for the current request's HTTP method
37
62
38
-
## Prior art
63
+
## Prior art 🖼️
64
+
65
+
- The `render_view` decorator was forked from `render_to` in https://github.com/skorokithakis/django-annoying.
66
+
- The `file`, `favicon_file` and `favicon_emoji` code is from https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/.
39
67
40
-
- The `render_view` decorator was forked from `render_to` in the delightful https://github.com/skorokithakis/django-annoying library.
41
-
- The `file`, `favicon_file` and `favicon_emoji` code is from the superb https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/ blog post.
0 commit comments