1

I am a php programmer, I have built some REST based solutions in php. Now I am learning python/django. I want to make a REST based solution in Django ( only for knowledge purpose ). I do not want to use any of REST frameworks/toolkits as This project is more a exploring django/python say how they work with raw REST concept.

I searched on net, But examples/tutorial filled on already built solutions. I also checkout for request method based filtering. I am thinking of two approaches.

Either urls.py have way to check request method and transfer to respective method in views.py.
Or I can add a pre load hook/class which determine request method on application initialize, And called respective method so overriding urls.py behavior (my preferred method).

If anybody can suggest a django way to do this?

Update : I found some interesting comments on SO, like https://stackoverflow.com/a/20898410/1230744 AND https://stackoverflow.com/a/1732520/1230744. Need to check if they can have the solution, I am searching.

Cœur
  • 37,241
  • 25
  • 195
  • 267
kuldeep.kamboj
  • 2,566
  • 3
  • 26
  • 63
  • 1
    This is a question and answer site. This should be a question, but appears to be a statement. Anyway, good luck! – monkut Feb 03 '14 at 08:05

2 Answers2

1

Well I get the answer of my questions finally from following link. It is possible through using Class based Views + serialization.

Restful routes and Django

Snippet links in side above link gave pretty much example to gave quite picture of how one can create a REST Api using only Django Core. Also I used serialize https://docs.djangoproject.com/en/dev/topics/serialization/ for Json encoding

( Now if anybody prefer, he can flag duplicate the question. ;) )

Community
  • 1
  • 1
kuldeep.kamboj
  • 2,566
  • 3
  • 26
  • 63
0

You can start from learning the code of this projects:

They are snadrd de facto for REST API for Django and their code could be a good starting point.

Also, please review this questions:

Community
  • 1
  • 1
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
  • REST is not very hard thing in concept, So making a small app on pure REST concepts, should not need to learn a full fledged application source code. I agree they must have done a good code architecture. But my requirement is so small. Meanwhile I have found something interesting as I linked in my updated answer. If they works then that should be what I am searching. Just small and clear. – kuldeep.kamboj Feb 03 '14 at 09:25