python -m django --version
1.11.3
cd /host/root/data/django_phone
export project_name=django_phone
django-admin startproject $project_name
cd $project_name
ls
django_phone manage.py
curl -s https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore > .gitignore
sed -i "s/^ALLOWED_HOSTS.*/ALLOWED_HOSTS = ['*']/" $project_name/settings.py
python manage.py runserver 0:8000
python manage.py startapp contacts
ls -R
.: contacts django_phone manage.py ./contacts: __init__.py admin.py apps.py migrations models.py tests.py views.py ./contacts/migrations: __init__.py ./django_phone: __init__.py __pycache__ settings.py urls.py wsgi.py ./django_phone/__pycache__: __init__.cpython-36.pyc urls.cpython-36.pyc settings.cpython-36.pyc wsgi.cpython-36.pyc
python manage.py makemigrations contacts
Migrations for 'contacts': contacts/migrations/0002_contact_sync.py - Add field sync to contact
python manage.py sqlmigrate contacts 0001
BEGIN; -- -- Create model Contact -- CREATE TABLE "contacts_contact" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL, "vcard" text NOT NULL); COMMIT;
python manage.py migrate
Operations to perform: Apply all migrations: admin, auth, contacts, contenttypes, sessions Running migrations: Applying contacts.0002_contact_sync... OK
python manage.py createsuperuser
pip install djangorestframework
Requirement already satisfied: djangorestframework in /opt/conda/lib/python3.6/site-packages
curl -H 'Accept: application/json; indent=4' -u user:password http://127.0.0.1:8000/api/contacts/
{ "count": 2, "next": null, "previous": null, "results": [ { "url": "http://127.0.0.1:8000/api/contacts/1/", "name": "n1", "vcard": "v1" }, { "url": "http://127.0.0.1:8000/api/contacts/2/", "name": "n2", "vcard": "v2" } ] }
pip install django-filter
Collecting django-filter Downloading django_filter-1.0.4-py2.py3-none-any.whl (43kB) 23% |███████▋ | 10kB 48kB/s eta 0:00:01 47% |███████████████▏ | 20kB 90kB/s eta 0:00:01 71% |██████████████████████▊ | 30kB 134kB/s eta 0:00:01 94% |██████████████████████████████▎ | 40kB 130kB/s eta 0:00:01 100% |████████████████████████████████| 51kB 161kB/s Installing collected packages: django-filter Successfully installed django-filter-1.0.4