django-small-view-set 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-small-view-set
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A lightweight Django ViewSet alternative with minimal abstraction.
5
5
  Home-page: https://github.com/nateonguitar/django-small-view-set
6
6
  License: MIT
@@ -21,10 +21,57 @@ Description-Content-Type: text/markdown
21
21
 
22
22
  A lightweight Django ViewSet alternative with minimal abstraction. This library provides a simple and transparent way to define API endpoints without relying on complex abstractions.
23
23
 
24
+ ## Getting Started with Django Small View Set
25
+
26
+ This guide provides a simple example to get started with the library.
27
+
28
+ ### Example Usage
29
+
30
+ Here’s how you can define a basic API endpoint with one collection route and one detail route:
31
+
32
+ ```python
33
+ from django.http import JsonResponse
34
+ from django.urls import path
35
+ from small_view_set.small_view_set import SmallViewSet
36
+ from small_view_set.decorators import default_handle_endpoint_exceptions
37
+
38
+ class BarViewSet(SmallViewSet):
39
+
40
+ def urlpatterns(self):
41
+ return [
42
+ path('api/bars/', self.default_router, name='bars_collection'),
43
+ path('api/bars/<int:pk>/', self.default_router, name='bars_detail'),
44
+ ]
45
+
46
+ @default_handle_endpoint_exceptions
47
+ def list(self, request, *args, **kwargs):
48
+ self.protect_list(request)
49
+ return JsonResponse({"message": "Hello, world!"}, status=200)
50
+
51
+ @default_handle_endpoint_exceptions
52
+ def retrieve(self, request, pk, *args, **kwargs):
53
+ self.protect_retrieve(request)
54
+ return JsonResponse({"message": f"Detail for ID {pk}"}, status=200)
55
+ ```
56
+
57
+
58
+ ## Registering in `urls.py`
59
+
60
+ To register the viewset in your `urls.py`:
61
+
62
+ ```python
63
+ from api.views.bar import BarViewSet
64
+
65
+ urlpatterns = [
66
+ # Other URLs like admin, static, etc.
67
+
68
+ *BarViewSet().urlpatterns(),
69
+ ]
70
+ ```
71
+
72
+
24
73
  ## Documentation
25
74
 
26
- - [Getting Started](./README_SIMPLE.md): A bare-bones example to get the fundamentals.
27
- - [Register URLs](./README_REGISTER_URLS): How to register viewset urls.
28
75
  - [Custom Endpoints](./README_CUSTOM_ENDPOINT.md): Learn how to define custom endpoints alongside the default router.
29
76
  - [Handling Endpoint Exceptions](./README_HANDLE_ENDPOINT_EXCEPTIONS.md): Understand how to write your own decorators for exception handling.
30
77
  - [Custom Protections](./README_CUSTOM_PROTECTIONS.md): Learn how to subclass `SmallViewSet` to add custom protections like logged-in checks.
@@ -3,7 +3,7 @@ small_view_set/__init__.py,sha256=FoYcTj03W41-w0jC1EOv1_VD4iBxO_03fIr_plSKnp8,44
3
3
  small_view_set/decorators.py,sha256=OSwGz5SfTw7hUjOcPNmCmUl8mLqaHOMXaLcqg9JBHXo,6750
4
4
  small_view_set/exceptions.py,sha256=8CAnzvNZFlqjez8z66jLo-4P3Tlj5Y5MioDPmrb9wQg,948
5
5
  small_view_set/small_view_set.py,sha256=THDeJp1PmodaWzFUUnowpDmhH8w1El4p97jvQnjyU4k,5192
6
- django_small_view_set-0.1.1.dist-info/LICENSE,sha256=M4ZuHeiGHHuewaZyqz7tol4E6E2GMz7fF1ywNoXD1tA,1069
7
- django_small_view_set-0.1.1.dist-info/METADATA,sha256=VlodbbAiq9mpZZmto8GTyoH0j1Ff2mTHyia-Kaw6Tlk,1719
8
- django_small_view_set-0.1.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
9
- django_small_view_set-0.1.1.dist-info/RECORD,,
6
+ django_small_view_set-0.1.3.dist-info/LICENSE,sha256=M4ZuHeiGHHuewaZyqz7tol4E6E2GMz7fF1ywNoXD1tA,1069
7
+ django_small_view_set-0.1.3.dist-info/METADATA,sha256=CfEGIqD7i2PPsYsDf-k8ksloNXlOGCutgaaqhH_BQd8,2881
8
+ django_small_view_set-0.1.3.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
9
+ django_small_view_set-0.1.3.dist-info/RECORD,,