#Django Rest Framework basics operation
- Create virtualenv using
Virtualenv env
command - Activate virtualenv using
env\Scripts\activate
for windows and for ubunutuenv\bin\activate
- Then install:
- pip install djangorestframework
- pip install markdown
- pip install django-filter
- Then next:
- django-admin startproject djangoLearning . #dot is to create directory in the same folder.
- cd djangoLearning
- django-admin startapp quickstart
- cd ..
- Then run
python manage.py migrate
to apply django db changes and run server usingpython manage.py runserver
- Now create models in your app i.e., here in quickstart.
- For simplicity, we can create models from existing db tables using
python manage.py inspectdb {tableName}
- Or we can create a model here and migrate the changes in the db using migrate command.
- For simplicity, we can create models from existing db tables using
- Once models are done, create the respective serializer class mentioning the models and fields required.
- Then create ViewSets in views to perform post, get etc. operations on it.
- Then register the url in urls.py in main project.
- Then you are good to go 👍