- Create Signup, Login and Logout APIs (No frontend needed)
- Create an upload API using which you can upload a CSV file and create Candidate (Name, Phone number) objects in the database Note: These candidates should be created with respect to the user.
- Create an API to obtain these candidates with pagination as 10.
creating virtualenv and install requirement
python3 -m venv env
pip install -r requirements.txt
celery -A config worker -l info
curl -X POST \ 'http://127.0.0.1:8000/api/user/register/' \ -H 'Accept: */*' \ -H 'User-Agent: Thunder Client (https://www.thunderclient.io)' \ --form 'username="developer"' \ --form 'email="ddd@gmail.com"' \ --form 'password="vinayak1@"' \ --form 'password2="vinayak1@"'
curl -X POST \ 'http://127.0.0.1:8000/api/user/login/' \ -H 'Accept: */*' \ -H 'User-Agent: Thunder Client (https://www.thunderclient.io)' \ -H 'Authorization: Token 316e7a138d986b54acce3e4dfb64e5f61f254cec' \ --form 'username="vinayak"' \ --form 'password="vinayak"'
make sure you have celery running
curl -X PUT \ 'http://127.0.0.1:8000/api/candidate/upload/' \ -H 'Accept: */*' \ -H 'User-Agent: Thunder Client (https://www.thunderclient.io)' \ -H 'Authorization: Token 74c07c1660babb615c5ad87a752c3dd7c6a9adef' \ -F 'file=@/home/vinayak/config/example_v.csv'
curl -X GET \ 'http://127.0.0.1:8000/api/candidate/show/' \ -H 'Accept: */*' \ -H 'User-Agent: Thunder Client (https://www.thunderclient.io)' \ -H 'Authorization: Token 74c07c1660babb615c5ad87a752c3dd7c6a9adef'
for speeding up and to optimize the creation of object in database with minimum hits. I have used .bulk_create(obj) method which hits database only once
code used :
with transaction.atomic(): Candidate.objects.bulk_create(obj)