- Python, pip installed
- Virtualenv installed via pip
- Postgresql
clone project Create virtualenv and activate virtualenv by run following cmds line by line
virtualenv env
.\env\scripts\activate (activate virtualenv)
You should see (env) at the head of cmd. All the following step require virtualenv is activated.
cd dlib-19.24.0
python setup.py install
Wait for dlib installed successfully. Install opencv and face_recognition
pip install opencv-python
pip install face_recognition
now install all the requirement packages listed in requirements.txt. Run following cmd in the root directory (same directory to requirements.txt).
pip install -r requirements.txt
If errors occur liên hệ Nam Anh. now try to run django server. Migration alert will occur because we havent connect and migrate model to DB.
python manage.py runserver
- open pgAdmin4
- Create new database name security
- connect the db to django.
- You can google it and follow the instruction.
After connect the database to django server. Run django server again to check db server connected successfully. Now migrate Django models to DB.
python manage.py makemigrations
python manage.py migrate
Open Querytool and run these cmds
create extension if not exists CUBE
ALTER TABLE accounts_myuser
add vec_low CUBE
ALTER TABLE accounts_myuser
add vec_high CUBE
create index accounts_myuser_vec_idx on accounts_myuser (vec_low, vec_high)
http://127.0.0.1:8000/accounts/auth/token/
http://127.0.0.1:8000/accounts/auth/token/refresh/
http://127.0.0.1:8000/accounts/ordinary/
- GET - list: Admin only.
- POST - register user: no Permission. =======
http://127.0.0.1:8000/accounts/ordinary/{id}/
- PUT - update: only Account owner or Admin.
- GET - retrieve: only Account owner or Admin.
- DELETE - detele: Only Account owner or Admin.
http://127.0.0.1:8000/accounts/admin/
- GET - list: only admin.
http://127.0.0.1:8000/accounts/admin/{pk}
- GET - retrieve admin detail: only Admin.
- example
search fields include username, first_name, email, phone, address Decendant ordered by birth, username
http://127.0.0.1:8000/accounts/ordinary/?ordering=-birth,-username
- ordering_fields = ['username', 'first_name', 'email', 'phone', 'address', 'visits__time', 'visits'] List accounts ordered by nearest visit
http://127.0.0.1:8000/accounts/ordinary/?ordering=-visits__time
or
http://127.0.0.1:8000/accounts/ordinary/?ordering=-visits__time
- Search through all accounts' attributes
- Search fields = ['username', 'first_name', 'email', 'phone', 'address']
- We can use both filter and search
http://127.0.0.1:8000/accounts/ordinary/?search=092393123
http://127.0.0.1:8000/accounts/ordinary/?ordering=-birth,-username&search=BuiNgocNam
http://127.0.0.1:8000/accounts/ordinary/?ordering=-birth&search=namanhble14012002@gmail.com
All the response data will be paginated into pages. Here is the sample format
{
"next": null,
"previous": null,
"num_pages": 1,
"count": 4,
"results": [
{
"pk": 8,
"username": "tony123",
"first_name": "Bui",
"last_name": "NamAnh",
"email": "namanh12@gmail.com",
"phone": "0796518081",
"address": "Ta quang buu",
"birth": "2022-10-31"
},
{
"pk": 7,
"username": "tony12",
"first_name": "Bui",
"last_name": "NamAnh",
"email": "namanh1@gmail.com",
"phone": "0796518081",
"address": "Ta quang buu",
"birth": "2022-10-31"
},
]
}