1. Alexander Lyabah: alexander@lyabah.com
~$ git clone https://github.com/oduvan/happy-evil.git
Cloning into happy-evil...
[ … ]
Resolving deltas: 100% (38/38), done.
~$ git checkout v0.0
git checkout v0.0
Note: checking out 'v0.0'.
[ … ]
HEAD is now at 8bb7a86... initial django
2. Что есть в начале?
~$ python --version
Python 2.7.3
~$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 12.10
Release: 12.10
Codename: quantal
3. Installation VirtualEnv
~$ sudo aptitude install python-virtualenv
[sudo] password for oduvan:
The following NEW packages will be installed:
[ … ] python-pip{a} python-setuptools{a} python-virtualenv
0 packages upgraded, 13 newly installed, 0 to remove and 0 not
upgraded.
[ … ]
Setting up build-essential (11.5ubuntu3) ...
~$ cd envs/
~/envs$ virtualenv he
New python executable in he/bin/python
Installing distribute................done.
Installing pip...............done.
~/envs$ source he/bin/activate
(he)~/envs$
4. Installation Django
(he)~/envs$ pip install django
Downloading/unpacking django
Downloading Django-1.4.2.tar.gz (7.7Mb): 7.7Mb
downloaded
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.7/django-
admin.py from 664 to 775
changing mode of
/home/oduvan/envs/he/bin/django-admin.py to 775
Successfully installed django
Cleaning up...
5. StartProject – создание проекта
(he)~/envs$ mkdir ~/www
(he)~/envs$ cd ~/www/
(he)~/www$ django-admin.py startproject he
(he)~/www$ ls
he
(he)~/www$ cd he/
(he)~/www/he$ ls
he manage.py
(he)~/www/he$ ls he/
__init__.py settings.py urls.py wsgi.py
6. Runserver – первый запуск
(he)~/www/he$ python manage.py runserver 0:8001
Validating models...
0 errors found
Django version 1.4.2, using settings 'he.settings'
Development server is running at http://0:8001/
Quit the server with CONTROL-C.
V0.0
7. Первый темплейт
● get_folder
● Первая вьюха
● Первый урл
● Первый темплей
16. Подключаем Базу Данных
● Настройки
● Установка postgresql и компонентов для
работы с python
● requirements.txt
17. Валера, настало твое время
(he)~/www/he$ python manage.py runserver 0:8001
Validating models...
Unhandled exception in thread started by <bound method
Command.inner_run of
<django.contrib.staticfiles.management.commands.runserver.Co
mmand object at 0x235be90>>
Traceback (most recent call last):
File "/home/oduvan/envs/he/local/lib/python2.7/site-
packages/django/core/management/commands/runserver.py", line
91, in inner_run
self.validate(display_num_errors=True)
[ … ]
import psycopg2.extensions
ImportError: No module named psycopg2.extensions
18. Ад ( … миним … )
(he)~/www/he$ sudo aptitude install postgresql libpq-
dev python-dev
[ … ]
Configuring postgresql.conf to use port 5432...
update-alternatives: using
/usr/share/postgresql/9.1/man/man1/postmaster.1.gz to
provide /usr/share/man/man1/postmaster.1.gz
(postmaster.1.gz) in auto mode
* Starting PostgreSQL 9.1 database server [ OK ]
Setting up postgresql (9.1+136) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for sgml-base ...
Updating the super catalog...
(he)~/www/he$ pip install psycopg2
Downloading/unpacking psycopg2
[ … ]
/temp.linux-x86_64-2.7/psycopg/microprotocols_proto.o
build/temp.linux-x86_64-2.7/psycopg/typecast.o -lpq -o
no previously-included directories found matching
'doc/src/_build'
Successfully installed psycopg2
Cleaning up...
19. Молодец, Валера! Отличная
работа!
(he)~/www/he$ python manage.py runserver 0:8001
Validating models...
0 errors found
Django version 1.4.2, using settings 'he.settings'
Development server is running at http://0:8001/
Quit the server with CONTROL-C.
[05/Dec/2012 05:27:15] "GET / HTTP/1.1" 200 1183
[05/Dec/2012 05:27:16] "GET /static/css/bootstrap.min.css
HTTP/1.1" 200 101265
[05/Dec/2012 05:27:16] "GET /static/js/jquery-1.8.3.min.js
HTTP/1.1" 200 93637
[05/Dec/2012 05:27:16] "GET /static/js/bootstrap.min.js
HTTP/1.1" 200 25743
26. Валера? PIL
(he)~/www/he$ python manage.py runserver 0:8001
Validating models...
Unhandled exception in thread started by <bound method
Command.inner_run of
<django.contrib.staticfiles.management.commands.runserver.Comm
and object at 0x2668f10>>
Traceback (most recent call last):
[ … ]
File "/home/oduvan/envs/he/local/lib/python2.7/site-
packages/django/core/management/base.py", line 270, in
validate
django.core.management.base.CommandError: One or more models
did not validate:
board.post: "photo": To use ImageFields, you need to install
the Python Imaging Library. Get it at
http://www.pythonware.com/products/pil/ .
(he)~/www/he$ pip install pil
(he)~/www/he$ pip freeze > requirements.txt
27. Syncdb
(he)oduvan@ubuntuServer12:~/www/he$ python manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table board_post
Creating table django_admin_log
You just installed Django's auth system, which means you don't
have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'oduvan'):
E-mail address: alexander@lyabah.com
Password:
Password (again):
Superuser created successfully.
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)