How should I integrate Django-REST-API framework in an existing application or I have to create a new project?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Serialise choice text for IntegerField with choice
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
You do not need to begin a new project. The basic steps are:
pip install djangorestframework
rest_framework
to yourINSTALLED_APPS
And that's it.
I suggest you follow the Quickstart and step through the Tutorial — it's pretty welcoming really.
I hope that helps.
I created a short note about how to do this with the photo gallery app tutorial from the Forcier et. al. book. I'm a Django noob, so please take this stuff as not-authoritative-perhaps-not-even-good. Here's the link to the post:
http://riceball.com/d/content/how-add-rest-api-existing-django-project
Basically, you create a new app, then in it write code for only three files: serializers.py, views.py, and urls.py. You don't write anything in models.py. Instead, you import the models from the existing app.
You then start off by creating serializers for all the models you want to expose, and then views for those serializers, and, finally, urls to call those views.