3 ms·
you have to start from the beginning and write an API now. Is it really that much more work? Much of the time the big difference is just be replacing retu
by dagw 5y ago
you have to start from the beginning and write an API now.
Is it really that much more work? Much of the time the big difference is just be replacing
return render(my_template, my_data)
with
return to_json(my_data)
- acdha 5y agoA few years back, I implemented this as a Django CBV which worked quite well: https://github.com/LibraryOfCongress/concordia/blob/main/concordia/api_views.py https://github.com/LibraryOfCongress/concordia/blob/main/con... That handles a few things like pagination for list views, calling get_absolute_url() on objects in the template context which have that method defined, and running all URLs through request.build_absolute_uri().