Python Girona 15/11/2017
Django App&API (Manel Clos) + React client (Francesc Arpí)
$ virtualenv venv
New python executable in /.../pygrn/venv/bin/python
Installing setuptools, pip, wheel...done.
$ . venv/bin/activate
(venv) $
(venv) $ pip install django
Collecting django
Downloading Django-1.11.7-py2.py3-none-any.whl (6.9MB)
100% |████████████████████████████████| 7.0MB 163kB/s
Collecting pytz (from django)
Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
100% |████████████████████████████████| 512kB 1.9MB/s
Installing collected packages: pytz, django
Successfully installed django-1.11.7 pytz-2017.3
(venv) $ django-admin startproject todos_project
(venv) $ cd todos_project/
(venv) $ dir -l
total 8
-rwxr-xr-x 1 manel staff 811 Nov 6 20:12 manage.py
drwxr-xr-x 6 manel staff 204 Nov 6 20:12 todos_project
(venv) $ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 13 unapplied migration(s). Your project may not work
properly until you apply the migrations for app(s): admin, auth,
contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
November 06, 2017 - 19:14:10
Django version 1.11.7, using settings 'todos_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
(venv) $ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
(venv) $ python manage.py createsuperuser
Username (leave blank to use 'manel'): admin
Email address:
Password:
Password (again):
Superuser created successfully.
(venv) $ python manage.py runserver
(venv) $ python manage.py startapp todos
(venv) $ python manage.py makemigrations todos
Migrations for 'todos':
todos/migrations/0001_initial.py
- Create model Todo
(venv) $ python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, todos
Running migrations:
Applying todos.0001_initial... OK
class QuestionAdmin(admin.ModelAdmin):
# ...
list_display = ('question_text', 'pub_date')
list_filter = ['pub_date']
search_fields = ['question_text']
(venv) $ pip install djangorestframework
Collecting djangorestframework
Downloading djangorestframework-3.7.3-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 679kB/s
Installing collected packages: djangorestframework
Successfully installed djangorestframework-3.7.3