Last active
October 21, 2017 11:59
-
-
Save guilatrova/3556856f02e59f4dd85ebb34b07c6b22 to your computer and use it in GitHub Desktop.
Latrova Commits DRF Tests 1.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import url | |
from django.conf.urls import url, include | |
from django.contrib import admin | |
urlpatterns = [ | |
url(r'^admin/', admin.site.urls), | |
url(r'^transactions/', include('transactions.urls')) | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import url | |
from transactions import views | |
list_actions = { | |
'get': 'list', | |
'post': 'create' | |
} | |
single_actions = { | |
'get': 'retrieve', | |
'put': 'update', | |
'patch': 'partial_update', | |
'delete': 'destroy' | |
} | |
urlpatterns = [ | |
url(r'^$', views.TransactionViewSet.as_view(list_actions), name="transactions"), | |
url(r'^(?P<pk>\d+)$', views.TransactionViewSet.as_view(single_actions), name='transaction'), | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import viewsets | |
from transactions.models import Transaction | |
from transactions.serializers import TransactionSerializer | |
class TransactionViewSet(viewsets.ModelViewSet): | |
queryset = Transaction.objects.all() | |
serializer_class = TransactionSerializer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment