RESTful API Ultimate Version Serialization package

Source: Internet
Author: User

URLs

 fromDjango.conf.urlsImportURL fromApp01ImportViewsurlpatterns= [    #URL (r "comment/$", Views.Comment.as_view ()),URL (r"comment/(? p<pk>\d+)", Views.CommentDetailView.as_view ()), URL (r"article/$", views. Article.as_view ()), URL (r"school/(? p<id>\d+)", views. Schooldetail.as_view (), name="School-detail"), url (r"school_view/$", views. Schoolview.as_view (), name="School_view-detail"), url (r"comment_view/$", Views.CommentView.as_view (), name="Comment_view-detail"), url (r"article/(? p<pk>\d+)", views. Articledetail.as_view (), name="Article-detail"),    #URL (r ' comment/$ ', Views.CommentViewSet.as_view ({    #" get": "List",    #" put": "Create",    # })),    #    #URL (r ' comment/(? p<pk>\d+)/$ ', Views.CommentViewSet.as_view ({    #" get": "Retrieve",    #" put": "Update",    #"Delete": "Destroy"    # }))] fromRest_framework.routersImportDefaultrouterrouter=Defaultrouter () router.register (R'Comment', Views.commentviewset) urlpatterns+=Router.urls#the equivalent of adding in Urlpatterns:    #URL (r ' comment/$ ', Views.CommentViewSet.as_view ({        #" get": "List",        #" put": "Create",        # })),        #        #URL (r ' comment/(? p<pk>\d+)/$ ', Views.CommentViewSet.as_view ({        #" get": "Retrieve",        #" put": "Update",        #"Delete": "Destroy"        # }))

Views: Here is the ultimate version of RESTful API:

 fromDjango.shortcutsImportRender,httpresponse fromDjango.httpImportJsonresponse fromApp01ImportModels fromRest_frameworkImportserializers fromDjangoImport views fromRest_framework.viewsImportApiview fromRest_framework.responseImportResponse fromApp01Importserializers as App01_serializers fromRest_framework.genericsImportGenericapiview fromRest_framework.mixinsImportlistmodelmixin,createmodelmixin,retrievemodelmixin,updatemodelmixin,destroymodelmixin fromRest_framework.genericsImportGenericapiview, Retrieveupdatedestroyapiview, Listcreateapiview fromRest_framework.viewsetsImportModelviewset fromDjango.conf.urlsImportURL fromApp01ImportViewsurlpatterns= [    #URL (r "comment/$", Views.Comment.as_view ()),URL (r"comment/(? p<pk>\d+)", Views.CommentDetailView.as_view ()), URL (r"article/$", views. Article.as_view ()), URL (r"school/(? p<id>\d+)", views. Schooldetail.as_view (), name="School-detail"), url (r"school_view/$", views. Schoolview.as_view (), name="School_view-detail"), url (r"comment_view/$", Views.CommentView.as_view (), name="Comment_view-detail"), url (r"article/(? p<pk>\d+)", views. Articledetail.as_view (), name="Article-detail"),    #URL (r ' comment/$ ', Views.CommentViewSet.as_view ({    #" get": "List",    #" put": "Create",    # })),    #    #URL (r ' comment/(? p<pk>\d+)/$ ', Views.CommentViewSet.as_view ({    #" get": "Retrieve",    #" put": "Update",    #"Delete": "Destroy"    # }))] fromRest_framework.routersImportDefaultrouterrouter=Defaultrouter () router.register (R'Comment', Views.commentviewset) urlpatterns+=Router.urls#the equivalent of adding in Urlpatterns:    #URL (r ' comment/$ ', Views.CommentViewSet.as_view ({        #" get": "List",        #" put": "Create",        # })),        #        #URL (r ' comment/(? p<pk>\d+)/$ ', Views.CommentViewSet.as_view ({        #" get": "Retrieve",        #" put": "Update",        #"Delete": "Destroy"        # }))

RESTful API Ultimate Version Serialization package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.