Dkova Dkova - 3 months ago 18
Python Question

Django rest framework api

I want to add to my Django project (using Django rest framework ) new get function.
I want it to just send to me in Json "Hello world" without writing or without opening a table in the DB
this is my code:

@api_view()
def about(request):
return Response({"message": "Hello, world!"})


i put it in view.py
what more i should do the make it work?
when i run the server and write this lines

http://127.0.0.1:8000/about


i want it to saw me "
{"message": "Hello, world!"}
"

Answer

Update your 'urls.py':

urlpatterns = patterns('',
    ...
    url(r'^about/$', views.about),
    ...
Comments