can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread kk
Dear all, I wish to know if I need to do some thing special for consuming a RESTfull server from some other provider? What should I do in the views? Do I need the complete DRF to do this? Can I do this with just Django's views and then send data across to templates? I mean, can I write views to

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread Avraham Serour
you don't need DRF at all, DRF will help you write REST servers if you need to consume you can just use requests ( http://docs.python-requests.org/en/latest/) On Tue, Nov 3, 2015 at 1:44 PM, kk wrote: > Dear all, > I wish to know if I need to do some thing special for consuming a RESTfull > ser

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread Remco Gerlich
Django code is just normal Python. Python can call REST APIs, sure (a nice library is Requests: docs.python-requests.org/en/latest/ ) Doing this in the view means that the user has to wait until the request ends before he gets a response. Possibly this will make the view too slow. You could also d

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread kk
On Tuesday 03 November 2015 08:35 PM, Remco Gerlich wrote: Django code is just normal Python. Python can call REST APIs, sure (a nice library is Requests: docs.python-requests.org/en/latest/ ) I got to see this, thanks, had a quick look and it ex

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-03 Thread Gergely Polonkai
On 4 Nov 2015 05:45, "kk" wrote: > > > > On Tuesday 03 November 2015 08:35 PM, Remco Gerlich wrote: >> >> Django code is just normal Python. Python can call REST APIs, sure (a nice library is Requests: docs.python-requests.org/en/latest/ ) >> > I got to see this, thanks, had a quick look and it e

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-04 Thread kk
Ok one question, I would like to store a client connection in some kind of a global place for my entire Django frontend. So that the request object can be used from any view. Can you suggest some guideline to do this? Happy hacking. Krishnakant. On Tuesday 03 November 2015 08:35 PM, Remco

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-04 Thread Gergely Polonkai
On 4 Nov 2015 17:31, "kk" wrote: > > > Ok one question, > I would like to store a client connection in some kind of a global place for my entire Django frontend. > So that the request object can be used from any view. > Can you suggest some guideline to do this? > Happy hacking. > Krishnakant.

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-04 Thread Avraham Serour
the question is why, why would you want to store a global connection for a REST server? keep in mind that you would be making HTTP requests, meaning even that you had a global variable holding the connection it would just open and close each tie you make a request. if you need t keep a connection

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-04 Thread kk
On Wednesday 04 November 2015 10:43 PM, Avraham Serour wrote: the question is why, why would you want to store a global connection for a REST server? keep in mind that you would be making HTTP requests, meaning even that you had a global variable holding the connection it would just open and

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-04 Thread marcin . j . nowak
> > > On Wednesday 04 November 2015 10:43 PM, Avraham Serour wrote: > So I have to use a client connection object such as Python request > So I want to keep it as global, so that all views can access it from a > single location, instead of creating a client request instance for every > view on

Re: can I write Django a client consuming RESTfull api from elsewhere

2015-11-05 Thread Jani Tiainen
Well your workflow would be following steps roughly: 1) End user requests URL from your Django site 2) Django router URL to a view 3) View code opens remote connection to RESTful service somewhere on the web 4) View code receive response from service 5) Data is processed 6) Data is rendered to end