Commit 181e4fdd by Tom Christie
parents f8a0d31d f317699d
...@@ -139,6 +139,7 @@ The following people have helped make REST framework great. ...@@ -139,6 +139,7 @@ The following people have helped make REST framework great.
* Pascal Borreli - [pborreli] * Pascal Borreli - [pborreli]
* Alex Burgel - [aburgel] * Alex Burgel - [aburgel]
* David Medina - [copitux] * David Medina - [copitux]
* Areski Belaid - [areski]
Many thanks to everyone who's contributed to the project. Many thanks to everyone who's contributed to the project.
...@@ -314,3 +315,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter. ...@@ -314,3 +315,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
[pborreli]: https://github.com/pborreli [pborreli]: https://github.com/pborreli
[aburgel]: https://github.com/aburgel [aburgel]: https://github.com/aburgel
[copitux]: https://github.com/copitux [copitux]: https://github.com/copitux
[areski]: https://github.com/areski
...@@ -10,7 +10,9 @@ A `ViewSet` class is only bound to a set of method handlers at the last moment, ...@@ -10,7 +10,9 @@ A `ViewSet` class is only bound to a set of method handlers at the last moment,
Let's take our current set of views, and refactor them into view sets. Let's take our current set of views, and refactor them into view sets.
First of all let's refactor our `UserListView` and `UserDetailView` views into a single `UserViewSet`. We can remove the two views, and replace then with a single class: First of all let's refactor our `UserList` and `UserDetail` views into a single `UserViewSet`. We can remove the two views, and replace then with a single class:
from rest_framework import viewsets
class UserViewSet(viewsets.ReadOnlyModelViewSet): class UserViewSet(viewsets.ReadOnlyModelViewSet):
""" """
...@@ -23,7 +25,6 @@ Here we've used `ReadOnlyModelViewSet` class to automatically provide the defaul ...@@ -23,7 +25,6 @@ Here we've used `ReadOnlyModelViewSet` class to automatically provide the defaul
Next we're going to replace the `SnippetList`, `SnippetDetail` and `SnippetHighlight` view classes. We can remove the three views, and again replace them with a single class. Next we're going to replace the `SnippetList`, `SnippetDetail` and `SnippetHighlight` view classes. We can remove the three views, and again replace them with a single class.
from rest_framework import viewsets
from rest_framework.decorators import link from rest_framework.decorators import link
class SnippetViewSet(viewsets.ModelViewSet): class SnippetViewSet(viewsets.ModelViewSet):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment