3

I have a web written in Django framework and created Rest Framework for the API. I am required to write an android application based on the Django framework (Android and Django newbie).

However I do not know how to pass the data from android (user input) into database MYSQL through Django Rest Framework. I done a lot of research in past 2 weeks, but still I cannot see any solution (text tutorial, video tutorial, code example) related to this issue.

Note: I will not using any PHP script and looking forward integrate with Django Rest Framework.

Let's have a testing example API from Django : http://json-api.jerel.co/entries

User input field from android: blog, headline, body text, pub date, mod date, authors

Which class/library in android involved? Volley? httpUrl? Json?

I appreciate that anyone can share a simple code to get this done.

======================================================================

FYI,

Database: MYSQL

Server : CentOS

Web : Python - Django

Android : Android studio

============================================================================ After tried all the solutions on net, and excluded those apache http client deprecated post, this is the workable and simplest solution (in my opinion):

https://stackoverflow.com/a/33937147/2466516 Thanks to Nitro.

Community
  • 1
  • 1
CHAN HAU YEEN
  • 343
  • 2
  • 5
  • 18
  • Possible duplicate of [Sending POST data in Android](http://stackoverflow.com/questions/2938502/sending-post-data-in-android) – Pawel Miech Aug 19 '16 at 06:10
  • @PawelMiech In my case I will not using PHP scripts but my intention is to integrate with Django REST framework. – CHAN HAU YEEN Aug 19 '16 at 07:21
  • yeah but you just need to make HTTP POST request to web app from android. It doesn't matter what you have on server. – Pawel Miech Aug 19 '16 at 08:09

2 Answers2

0

@chan-hau-yeen, you will want to look at something like Retrofit2 for Android to handle the network post to your Django backend. You can create json objects to post to your backend. Then with django you can accept the json and handle it there.

Ray Hunter
  • 15,137
  • 5
  • 53
  • 51
0

Once you have created api end points using DRF with data in json . You can use volley library for handling network calls . Here is the link which shows how make network calls and json parsing . http://www.androidhive.info/2014/09/android-json-parsing-using-volley/

patel
  • 186
  • 9
  • Thanks Patel. I able to connect to json and retrieve data from json. How about save user input into database passby Django Rest Framework? – CHAN HAU YEEN Aug 22 '16 at 01:38