In [1]:
python -m django --version
1.11.3
In [2]:
cd /host/root/data/django_phone
Out[2]:

startproject

In [22]:
export project_name=django_phone
Out[22]:
In [ ]:
django-admin startproject $project_name
cd $project_name
In [29]:
ls
Out[29]:
django_phone  manage.py
In [30]:
curl -s https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore > .gitignore
sed -i "s/^ALLOWED_HOSTS.*/ALLOWED_HOSTS = ['*']/" $project_name/settings.py
Out[30]:
In [ ]:
python manage.py runserver 0:8000

startapp

In [31]:
python manage.py startapp contacts
Out[31]:
In [32]:
ls -R
Out[32]:
.:
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

migrate

In [7]:
python manage.py makemigrations contacts
Out[7]:
Migrations for 'contacts':
  contacts/migrations/0002_contact_sync.py
    - Add field sync to contact
In [3]:
python manage.py sqlmigrate contacts 0001
Out[3]:
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;
In [8]:
python manage.py migrate
Out[8]:
Operations to perform:
  Apply all migrations: admin, auth, contacts, contenttypes, sessions
Running migrations:
  Applying contacts.0002_contact_sync... OK

User

In [ ]:
python manage.py createsuperuser
In [1]:
pip install djangorestframework
Out[1]:
Requirement already satisfied: djangorestframework in /opt/conda/lib/python3.6/site-packages
In [5]:
curl -H 'Accept: application/json; indent=4' -u user:password http://127.0.0.1:8000/api/contacts/
Out[5]:
{
    "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"
        }
    ]
}
In [9]:
pip install django-filter
Out[9]:
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