6

I am developing a mobile app which is using Ionic (AngularJS) as the frontend and Django as the backend. I wanted to know if it is possible to use Django to expose data as a JSON web API that my app will consume through $http services. If so, how would I go about doing it?

methuselah
  • 12,766
  • 47
  • 165
  • 315

2 Answers2

6

I'm doing exactly the same so YES that works nicely!

Have a look at:

http://www.django-rest-framework.org/

It will provide you with a flexible REST framework to serve your data.

On the angularjs side, I personally would use $resource instead of $http as the promises are more flexible in my opinion. Especially the chaining using $q.all() can be very useful.

Once you get to the authorization of users, have a look here:

Authorization header in AngularJS not working

on some tips on how to get django rest talking with our app.

Community
  • 1
  • 1
Niels van Eldik
  • 211
  • 2
  • 7
2

Have a look at this video for a great intro into using Django with Django Rest Framework and Angular:

https://www.youtube.com/watch?v=GVDjoTt3r8A

Sample app mentioned in video can be found here:

https://github.com/TrackMaven/Djangular

Softinio
  • 638
  • 1
  • 6
  • 19
  • That looks like a nice example to get started. However keep in mind that it will not allow you to deploy your frontend as a separate app as in the example the code is still hosted by django. If you intend to host your backend from a different domain as the frontend you will need to do a little bit more work and implement an independent REST API. – Niels van Eldik Nov 11 '15 at 18:50