1. Install Django
Download the latest version from Django website
tar xzvf Django-xxx.tar.gz
cd Django-xxx
python setup.py install
2. Check the version of Django
>>>python
>>>import django
>>>django.get_version()
3. Install MySQL
apt-get install python-mysqldb
4. Start a new project
django-admin.py startproject project_name
cd project_name
python manage.py runserver
  p.s the website will be 127.0.0.1:8000 if success
5. edit project_name/settings.py
vi settings.py
   DATABASES={
     'ENGINE':'django.db.backends.mysql'
     'NAME':'the database name'
     'USER':'root'
     'PASSWORD:'xxxxxxx'
   }
TIME_ZONE='Asia/Taipei'
LANGUAGE_CODE='zh-TW'
6. Create database for the project
mysql -u root -p
  CREATE DATABASE name;
  exit;
python manage.py syncdb
enter 'yes' to create Django's auth system account
7. Visite the Django's auth system
vi setting.py
  remove # of "INSTALLED_APPS->django.contrib.admin"
vi urls.py
  remove # of "from django.contrib import admin"
  remove # of "admin.autodiscover()"
  remove # of "urlpattenrs->url(r'^admin/',include(admin.site.urls))"
go to 127.0.0.1:8000/admin
  p.s if success, we will see:
沒有留言:
張貼留言