DjangoCamp:tohyo:ミニブログ投票

hdknr@deb09:~/tohyo$ hg clone ssh://hg@bitbucket.org/hdknr/tohyo
destination directory: tohyo
no changes found
updating working directory
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

hdknr@deb09:~/tohyo/tohyo$ mkdir trunk tags branches
hdknr@deb09:~/tohyo/tohyo$ hg add *
hdknr@deb09:~/tohyo/tohyo$ hg commit -u hdknr -m"#1 create repository"
nothing changed
hdknr@deb09:~/tohyo/tohyo$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
no changes found
hdknr@deb09:~/tohyo/tohyo$ hg add trunk tags branches

つまり、ファイルがないとコミットできない。

hdknr@deb09:~/tohyo/tohyo/trunk$ more ../../create.sh
#!/bin/sh

django-admin startproject tohyo
hdknr@deb09:~/tohyo/tohyo/trunk$ ../../create.sh
hdknr@deb09:~/tohyo/tohyo/trunk$ hg add tohyo/
hdknr@deb09:~/tohyo/tohyo/trunk$ hg commit -u hdknr -m"#1 create repository"
hdknr@deb09:~/tohyo/tohyo/trunk$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 4 changes to 4 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 179.7 KB in use, 150.0 MB available (0.12% used)

hdknr@deb09:~/tohyo/tohyo/trunk$ echo "CREATE DATABASE tohyo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" | sudo mysql
hdknr@deb09:~/tohyo/tohyo/trunk$ echo "grant all privileges on tohyo.* to ‘tohyo’@’localhost’ identified by ‘tohyo’"  | sudo mysql
hdknr@deb09:~/tohyo/tohyo/trunk$ mkdir mysql
hdknr@deb09:~/tohyo/tohyo/trunk$ sudo mysqldump tohyo -B > mysql/ddl.sql
hdknr@deb09:~/tohyo/tohyo/trunk$ hg add mysql
adding mysql/ddl.sql

hdknr@deb09:~/tohyo/tohyo/trunk$ hg commit -u hdknr -m "#2 create tohyo database"
hdknr@deb09:~/tohyo/tohyo/trunk$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 2 changes to 2 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 180.9 KB in use, 150.0 MB available (0.12% used)

hdknr@deb09:~/tohyo/tohyo/trunk$ cd tohyo/

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ python manage.py  startapp microblog
hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg add  microblog/
adding microblog/__init__.py
adding microblog/models.py
adding microblog/views.py

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg commit -u hdknr -m "#3 crate [[microblog]] applicatin"

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 3 changes to 3 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 181.7 KB in use, 150.0 MB available (0.12% used)

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/var/lib/python-support/python2.5/django/core/management/__init__.py", line 340, in execute_manager
    utility.execute()
  File "/var/lib/python-support/python2.5/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/python-support/python2.5/django/core/management/base.py", line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/var/lib/python-support/python2.5/django/core/management/base.py", line 210, in execute
    translation.activate(‘en-us’)
  File "/var/lib/python-support/python2.5/django/utils/translation/__init__.py", line 73, in activate
    return real_activate(language)
  File "/var/lib/python-support/python2.5/django/utils/translation/__init__.py", line 43, in delayed_loader
    return g[‘real_%s’ % caller](*args, **kwargs)
  File "/var/lib/python-support/python2.5/django/utils/translation/trans_real.py", line 209, in activate
    _active[currentThread()] = translation(language)
  File "/var/lib/python-support/python2.5/django/utils/translation/trans_real.py", line 198, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/var/lib/python-support/python2.5/django/utils/translation/trans_real.py", line 181, in _fetch
    app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:])
  File "/var/lib/python-support/python2.5/django/contrib/admin/__init__.py", line 1, in <module>
    from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
  File "/var/lib/python-support/python2.5/django/contrib/admin/options.py", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/var/lib/python-support/python2.5/django/contrib/contenttypes/models.py", line 1, in <module>
    from django.db import models
  File "/var/lib/python-support/python2.5/django/db/__init__.py", line 34, in <module>
    (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends)), e_user)
django.core.exceptions.ImproperlyConfigured: ‘tohyo’ isn’t an available database backend. Available options are: ‘dummy’, ‘mysql’, ‘oracle’, ‘postgresql’, ‘postgresql_psycopg2’, ‘sqlite3’
Error was: No module named base

ミス!
DATABASE_ENGINE = ‘mysql’           # ‘postgresql_psycopg2’, ‘postgresql’, ‘mysql’, ‘sqlite3’ or ‘oracle’.

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table microblog_note

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 ‘hdknr’): admin
E-mail address: admin@ic-tact.co.jp
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model
Installing index for microblog.Note model

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ echo "show tables" | sudo mysql tohyo
Tables_in_tohyo
auth_group
auth_group_permissions
auth_message
auth_permission
auth_user
auth_user_groups
auth_user_user_permissions
django_admin_log
django_content_type
django_session
django_site
microblog_note

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg add microblog/
adding microblog/__init__.pyc
adding microblog/admin.py
adding microblog/models.pyc

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ cd ..
hdknr@deb09:~/tohyo/tohyo/trunk$ sudo mysqldump tohyo -B > mysql/ddl.sql

hdknr@deb09:~/tohyo/tohyo/trunk$ hg commit -u hdknr -m "#4 add note to microblog"
hdknr@deb09:~/tohyo/tohyo/trunk$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 6 changes to 6 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 185.8 KB in use, 150.0 MB available (0.12% used)

hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg commit -u hdknr -m "#4 missing urls.py edit"
hdknr@deb09:~/tohyo/tohyo/trunk/tohyo$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 186.1 KB in use, 150.0 MB available (0.12% used)

pulling from ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 4 changes to 4 files
(run ‘hg update’ to get a working copy)
hdknr@deb09:~/tohyo/tohyo$ hg update
4 files updated, 0 files merged, 7 files removed, 0 files unresolved

hdknr@deb09:~/tohyo/tohyo/trunk$ vi mysql/mig.5.add_status_to_note.sql
alter table microblog_note add status int(11);
alter table microblog_note modify status int(11) not null default 0;

cat mysql/mig.5.add_status_to_note.sql | sudo mysql tohyo

hdknr@deb09:~/tohyo/tohyo/trunk$ echo "desc microblog_note" | sudo mysql tohyo -t
+———–+———-+——+—–+———+—————-+
| Field     | Type     | Null | Key | Default | Extra          |
+———–+———-+——+—–+———+—————-+
| id        | int(11)  | NO   | PRI | NULL    | auto_increment |
| author_id | int(11)  | NO   | MUL | NULL    |                |
| text      | longtext | NO   |     | NULL    |                |
| writed_at | datetime | NO   |     | NULL    |                |
| votes     | int(11)  | NO   |     | NULL    |                |
| status    | int(11)  | NO   |     | 0       |                |
+———–+———-+——+—–+———+—————-+

hdknr@deb09:~/tohyo/tohyo/trunk$ hg add mysql/mig.5.add_status_to_note.sql
hdknr@deb09:~/tohyo/tohyo/trunk$ hg commit -u hdknr -m "#5 status added to note"
hdknr@deb09:~/tohyo/tohyo/trunk$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 194.4 KB in use, 150.0 MB available (0.13% used)

hdknr@deb09:~/tohyo/tohyo/trunk$ sudo mysqldump -B -d tohyo > mysql/ddl.sql
hdknr@deb09:~/tohyo/tohyo/trunk$ hg commit -u hdknr -m "#5 ddl ,as of "
hdknr@deb09:~/tohyo/tohyo/trunk$ hg push
pushing to ssh://hg@bitbucket.org/hdknr/tohyo
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: bb/acl: hdknr is allowed. accepted payload.
remote: quota: 195.0 KB in use, 150.0 MB available (0.13% used)

カテゴリー: 未分類 パーマリンク

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中