博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简易博客开发(1)---- 新建开发环境和项目
阅读量:7203 次
发布时间:2019-06-29

本文共 2864 字,大约阅读时间需要 9 分钟。

  hot3.png

需求分析:

    1  博客主页, blog显示

    2  单张博客细节展示

    3  博客标签新建及归档

    4  博客评论系统

    5  博客在线编辑系统

    6  博客增,删,改,查功能

开发环境

1 install djangopip install django==1.8.82 install mysqlyum install mysql mysql-server mysql-devel -y3 install python-mysqlwget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/downloadtar -zxvf MySQL-python-1.2.3.tar.gz cd MySQL-python-1.2.3python setup.py build python setup.py install

 建立新项目myblog

[root@hding django]# django-admin.py startproject myblog[root@hding django]# tree myblog/myblog/|-- manage.py`-- myblog    |-- __init__.py    |-- settings.py    |-- urls.py    `-- wsgi.py
建立新应用
[root@hding django]# cd myblog/[root@hding myblog]# django-admin.py startapp blogmyblog/|-- blog|   |-- __init__.py|   |-- admin.py|   |-- migrations|   |   `-- __init__.py|   |-- models.py|   |-- tests.py|   `-- views.py|-- manage.py`-- myblog    |-- __init__.py    |-- settings.py    |-- urls.py    `-- wsgi.py
新建database blog

[root@hding myblog]# mysql -urootWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.0.95 Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database blog default charset utf8; Query OK, 1 row affected (0.00 sec)

编辑settings.py使得连接的数据库由默认的sqlite转为mysql,并且修改app

#myblog/myblog/settings.pyINSTALLED_APPS = (     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',                                                                   'django.contrib.messages',                                                                   'django.contrib.staticfiles',                                                                'blog',                                             #新建blog                                                                                 ) DATABASES = {      'default': {             'ENGINE':   'django.db.backends.mysql',     #更改默认数据库为mysql                                             'NAME':  'blog',                            #数据库名为blog, 这个数据库必需先建好,否则提示错误     } }
运行系统
[root@hding myblog]# python manage.py runserver 192.168.2.111:8000Performing system checks...System check identified no issues (0 silenced).You have unapplied migrations; your app may not work properly until they are applied.              #数据库建立好后没有同步Run 'python manage.py migrate' to apply them.February 09, 2016 - 15:36:47Django version 1.8.8, using settings 'myblog.settings'Starting development server at http://192.168.2.111:8000/Quit the server with CONTROL-C.

当这个画面出现时,说明django服务器成功搭建

转载于:https://my.oschina.net/hding/blog/614387

你可能感兴趣的文章
草长莺飞,总归一字
查看>>
HDOJ 2097
查看>>
计算机学科漫谈
查看>>
mac下配置openfire
查看>>
自定义控件实现(转)
查看>>
如何确认访客所在的国家
查看>>
跟着8张思维导图学习javascript
查看>>
InnoSQL/MySQL并行复制的实现与配置
查看>>
JDBC连接MySQL数据库及演示样例
查看>>
第38周五
查看>>
windows下Emacs的安装与配置
查看>>
WF4 常用类<第二篇>
查看>>
mongo文件空间
查看>>
NSArray中存的是实体时的排序
查看>>
搜索框中“请输入搜索keyword”
查看>>
CentOS6.5与XP双系统安装
查看>>
Python 更新set
查看>>
shell语法简单介绍
查看>>
Web服务器的工作原理
查看>>
使用WinSetupFromUSB来U盘安装windowsXP(不使用win PE系统)
查看>>