Django app example with autocomplete suggestions based on query.
Version: 0.4
- Python 3 🐍
- Django 2.1.3
- django-filter 2.0.0
- djangorestframework 3.9.0
- Markdown 3.0.1
- pytz 2018.7
- sortedcontainers 2.1.0
- PyTrie 0.3.1
URL Name | Http Method | Action | URL Style | Type of parameter |
---|---|---|---|---|
autocomplete | GET | List | /autocomplete/{query} | String |
git clone https://github.com/natanaelfneto/django_rest_autocomplete_tree.git
mkvirtualenv autocomplete
workon autocomplete
pip install -r requirements.ext
python src/manage.py test api
python src/manage.py runserver
- http://localhost:8000/autocomplete/query?format=api for REST Framework API format
or - http://localhost:8000/autocomplete/query?format=json for JSON format
Obs: remember to channge thequery
with a string to receire autocomplete suggestions
curl -X GET -H "Content-Type: application/json" http://localhost:8000/autocomplete/lee
HTTP 200 OK
Allow: OPTIONS, GET
Content-Type: application/json
Vary: Accept
{
"patients": [
"lee chambers",
"lee chavez",
"lee clark",
"lee hanson",
"lee price",
"leevi anttila",
"leevi takala"
]
}
python src/manage.py test api --pattern="long_tests.py"
Obs: insted of default random values, run test on all possible values
- ✔️ API with Django 2 and REST Framework [OK]
- ✔️ Django App to return suggestion for patients names based on query as JSON [OK]
- ✔️ Implementation of automated tests [OK]
- 🕓 Replace csv object with a database structure [PENDING]
- 🕓 Replace virtual environment and requirements file with an automatic pyenv dependecies control [PENDING]
- 🕓 Improve tests for a broadspects sets of values [PENDING]
- Own implemented tree class function with inheritance of python mapping
- Node object class for tree nodes instancies
- Null class for not interesting (complete) but true results of autocomplete routine
- Replaced Pytrie library with own tree solution
- Removed unecessary migrate command from readme
- Updated readme file
- Add requirements file
- Update commnetaries for better review on code
- Api app test to assert example request status value splited in single and all values
- Api app test to assert example request status value for all values commented due to its long runtime
- Added csv for patient data in ./assets/patient.csv
- Updated readme file
- Django project created
- Django app created for api
- Api django app view for patient autocomplete suggestion created
- Api app class for patients csv data base instance created
- Api app url created
- Api app test to assert request status value created
- Api app test to assert example request data value created
- Api app test response function to reduce code repetition
- Project folder created
- Django implemented
- Django REST Framework implemented