superuser: admin password: qwe123rt
- Create virtual environment in root directory of project -
python3.6 -m venv venv
source env/bin/activate
pip install -r requirements.txt
- Install PostgreSql =
sudo apt-get install postgresql postgresql-contrib
- Create user
createuser --interactive -P Enter name of role to add: root Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) y
- Create db
createdb comments
- Create tables
venv/bin/python3.6 manage.py migrate
- Create data
venv/bin/python3.6 manage.py fill_db
venv/bin/python3.6 manage.py test .
venv/bin/python3.6 manage.py runserver 8000
- Open in browser http://127.0.0.1:8000/
- Create new comment
- Get comments top level for entities:
- comment - http://127.0.0.1:8000/api/comment/comment/2/ where
second
comment
- it is entity identifier and2
- it is id of parent comment - post - http://127.0.0.1:8000/api/comment/post/2/ where
post
- it is entity identifier and2
- it is id of entity - user - http://127.0.0.1:8000/api/comment/user/2/ where
user
- it is entity identifier and2
- it is id of entity
- comment - http://127.0.0.1:8000/api/comment/comment/2/ where
second
- Get comments recursively for three entities:
- Get user history by comments - http://127.0.0.1:8000/api/user/2/comment/history/'
- Export user history to csv - http://127.0.0.1:8000/api/entity/user/2/comment/history/export/csv/
- Export user history to xml - http://127.0.0.1:8000/api/entity/user/2/comment/history/export/xml/
- Export comment history to xml - http://127.0.0.1:8000/api/entity/comment/2/comment/history/export/xml/
- Export post history to xml - http://127.0.0.1:8000/api/entity/post/2/comment/history/export/xml/
- Get history operations for some comment, by comment id - http://127.0.0.1:8000/api/comment/10/history/
- CRUD for comments - http://127.0.0.1:8000/admin/comments/comment/
- CRUD for users - http://127.0.0.1:8000/admin/auth/user/
- CRUD for posts - http://127.0.0.1:8000/admin/comments/post/
- Update requirements -
venv/bin/pip3.6 freeze > requirements.txt
venv/bin/python3.6 manage.py createsuperuser
- Написал на Django чтобы сэкономить время на реализации всего приложения(модели, orm, view).
- Подключил drf чтобы сгенерироваать интерфейсы средствами фреймворка.
- Экспорт файлов сделал через генераторы и отдаю через StreamingHttpResponse чтобы при большом объеме данных не падал запрос по таймауту.
- Выбрал PostgreSql так как больше всего у меня опыта именно с этой реляционной БД.