python django 快速搭建开发平台

python + mysql,

数据库文件已导入。


# check version
python -c "import django; print(django.get_version())"

#install pip
sudo apt-get install python-pip

#install newest django
sudo pip install django==1.4.5

#check version again
python -c "import django; print(django.get_version())"

#create new project file
django-admin.py startproject paaam

#add 777 to manage.py
cd paaam
chmod 777 manage.py

# run server
./manager.py runserver

#modify settings.py, uncomment out any admin.*
#add paaam to INSTALLED_APPS
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
     'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
     'django.contrib.admindocs',
     'paaam'
)

#load model entity to models.py

# https://docs.djangoproject.com/en/1.4/howto/legacy-databases/

./manage.py inspectdb > paaam/models.py
./manage.py syncdb

#if said 'ENGINE': 'django.db.backends.mysql' value is incorrect
sudo pip install mysql-python

#create admin.py, register model
 from django.contrib import admin
from paaam.models import (
    WpCommentmeta,
    WpComments,
    WpLinks,
    WpOptions,
    WpPostmeta,
    WpPosts,
    WpTermRelationships,
    WpTermTaxonomy,
    WpTerms,
    WpUsermeta,
    WpUsers,
)

admin.site.register(WpCommentmeta)
admin.site.register(WpComments)
admin.site.register(WpLinks)
admin.site.register(WpOptions)
admin.site.register(WpPostmeta)
admin.site.register(WpPosts)
admin.site.register(WpTermRelationships)
admin.site.register(WpTermTaxonomy)
admin.site.register(WpTerms)
admin.site.register(WpUsermeta)
admin.site.register(WpUsers)





你可能感兴趣的:(python)