
Sample Django/AngularJS2 code to handle POST call to Django REST Framework
- or -
Post a project like this3549
£20(approx. $27)
- Posted:
- Proposals: 3
- Remote
- #1110963
- Completed
Description
Experience Level: Intermediate
General information for the website: No important
Description of requirements/features: I have a Django REST Framework that needs to respond to POST and GET API calls from an Angular2 app. I need someone who is expert in Django REST Framework to create a small piece of sample code that does the following:
1) Examines the POST data and checks that the POSTed 'title' is all alphanumeric characters.
2) Responds to the API caller "{success: 'True', title: title}" if the validation was successful and the data record has been successfully created by Django REST Framework.
3) Respond to the API caller with "{success: 'False', reason: 'Title is not all alphanumeric'}" if the POSTed 'title' data failed the validation test. And aborts creating the new record.
4) The code must also make sure that the response to the API call reports other reasons for failure. For example the model requires that the 'title' field is unique. So the response to the API caller must make it clear why the record was not created if it was a duplicate.
The view your create MUST be called: class ItemViewSet(viewsets.ModelViewSet)
The serializer MUST be called: class ItemSerializer(serializers.HyperlinkedModelSerializer)
The model to be used is called: Item
The urlconf is as follows:
router = routers.DefaultRouter()
router.register(r'items', itemViews.ItemViewSet)
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS
url(r'^admin/', admin.site.urls),
]
Extra notes:
Description of requirements/features: I have a Django REST Framework that needs to respond to POST and GET API calls from an Angular2 app. I need someone who is expert in Django REST Framework to create a small piece of sample code that does the following:
1) Examines the POST data and checks that the POSTed 'title' is all alphanumeric characters.
2) Responds to the API caller "{success: 'True', title: title}" if the validation was successful and the data record has been successfully created by Django REST Framework.
3) Respond to the API caller with "{success: 'False', reason: 'Title is not all alphanumeric'}" if the POSTed 'title' data failed the validation test. And aborts creating the new record.
4) The code must also make sure that the response to the API call reports other reasons for failure. For example the model requires that the 'title' field is unique. So the response to the API caller must make it clear why the record was not created if it was a duplicate.
The view your create MUST be called: class ItemViewSet(viewsets.ModelViewSet)
The serializer MUST be called: class ItemSerializer(serializers.HyperlinkedModelSerializer)
The model to be used is called: Item
The urlconf is as follows:
router = routers.DefaultRouter()
router.register(r'items', itemViews.ItemViewSet)
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS
url(r'^admin/', admin.site.urls),
]
Extra notes:
Bill N.
84% (5)Projects Completed
5
Freelancers worked with
5
Projects awarded
22%
Last project
8 Apr 2016
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies