Coder Social home page Coder Social logo

yuta-inoue / multipart-form-data_django_rest_framework_tutorial Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ansother/multipart-form-data_django_rest_framework_tutorial

0.0 2.0 0.0 116 KB

multipart-form-data_django_rest_framework_tutorial

Python 100.00%

multipart-form-data_django_rest_framework_tutorial's Introduction

multipart-form-data_django_rest_framework_tutorial ======================================

About

date: 2012/11/25

This is a simple django-rest-framework multipart/form-data example.

Requirements

Setup was on ubuntu 12.04.

Django==1.4.2Pygments==1.5 argparse==1.2.1djangorestframework==2.1.6 wsgiref==0.1.2requests==0.14.2a

Installation and setup ---------------

  1. Download and cd into the multipart-form-data_django_rest_framework_tutorial:

    $ cd multipart-form-data_django_rest_framework_tutorial/

  2. Install requirements from the r.txt file with pip:

    $ pip install -r requirements.txt

  3. Setup database:

    $ python manage.py sncdb

  4. Run the Django development server:

    $ python manage.py runserver

Uploading files

This files provides commands to upload files to the django-rest-framework api.

  1. Open a python interpreter:

    $ python

  2. Import requests in python interpreter:

    $import requests

  3. Swap out the YOUR_URL in the url variables with your root url:

    $url_upload_form = 'YOUR_URL/api/upload_form/'

    $url_upload_serializers = 'YOUR_URL/api/upload_serializers/'

  4. Paste url variables into python interpreter:
  5. Create a file to up:

    $files = {'docfile': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}

  6. Upload a file with a form:

    $r=requests.post(url_upload_form, data={'title':'file_upload_form'}, files=files)

  7. Upload a file with django-rest-framework serializer:

    $r=requests.post(url_upload_serializers, data={'title':'file_upload_serializers'}, files=files)

  8. To view uploaded data in the django-rest-framework view go to:

    $YOUR_URL/api/upload_form/

    or

    $YOUR_URL/api/upload_serializers/

multipart-form-data_django_rest_framework_tutorial's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.