LoginSignup
10
10

More than 5 years have passed since last update.

Mac OSXでPythonフレームワークDjangoをはじめる

Last updated at Posted at 2014-06-18

PythonフレームワークDjangoのチュートリアルをMac環境ではじめるためのメモ。

環境チェック

% uname -a
Darwin grappa.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64

% python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

%  which python 
/usr/bin/python

インストール

Pythonパッケージマネージャーpipをインストール

sudo easy_install pip

djangoのインストール

sudo pip install django

Pythonプロンプトでインストールの確認

% python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.get_version()
1.6.5

1.6.5がインストールできた!

ついでにHomebrewで見つけた便利そうなな奴

brew install homebrew/completions/django-completion

チュートリアルをはじめる

Django1.4用だけど日本語チュートリアルがあったので最初の方やってみる

% django-admin.py startproject mysite
% tree mysite
mysite
├── manage.py
└── mysite
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

1 directory, 5 files
% python manage.py runserver
Validating models...

0 errors found
June 13, 2014 - 23:18:08
Django version 1.6.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

ブラウザで http://127.0.0.1:8000/ を開くとWelcome to Django!

Welcome to Django

Django Site Admin

-> % python manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session

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 'tumf'): 
Email address: y.takahara@gmail.com
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10