django框架创建应用操作示例

作者:zhaoyangjian724 时间:2022-07-15 22:07:33 

本文实例讲述了django框架创建应用操作。分享给大家供大家参考,具体如下:

18.1.5  安装Django

安装Django


node2:/root#pip install Django
/usr/local/python27/lib/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
utils.DeprecatedIn23,
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: Django in /usr/local/python27/lib/python2.7/site-packages (1.11.9)
Requirement already satisfied: pytz in /usr/local/python27/lib/python2.7/site-packages (from Django) (2017.2)
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

18.1.6  在Django 中创建项目:


node2:/django/mysite#django-admin.py startproject learning_log
node2:/django/mysite#ls -ltr
total 64
-rwxrwxrwx 1 root root 804 Oct 25 2017 manage.py
-rwxrwxrwx 1 root root 608 Nov 25 2017 query_mysql.py
drwxrwxrwx 3 root root 4096 Nov 27 2017 form
drwxrwxrwx 2 root root 4096 Nov 27 2017 online
-rwxrwxrwx 1 root root 262 Dec 5 2017 test.py
-rwxrwxrwx 1 root root 646 Dec 5 2017 test.pyc
-rwxrwxrwx 1 root root 113 Dec 5 2017 __init__.pyc
drwxrwxrwx 2 root root 4096 Dec 5 2017 home
-rwxrwxrwx 1 root root  0 Dec 5 2017 __init__.py
-rwxrwxrwx 1 root root  27 Dec 5 2017 a1.py
-rwxrwxrwx 1 root root  5 Dec 5 2017 celerybeat.pid
drwxrwxrwx 7 root root 4096 Dec 12 2017 static
drwxrwxrwx 4 root root 4096 Jan 28 2018 blog
drwxrwxrwx 2 root root 4096 Sep 16 2018 portal
drwxrwxrwx 2 root root 4096 Apr 24 10:15 mysite
drwxrwxrwx 4 root root 4096 Apr 25 02:17 news
drwxr-xr-x 3 root root 4096 Apr 25 09:25 learning_log

/django/mysite/learning_log/learning_log


INSTALLED_APPS = (
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'learning_log',

18.1.7 创建数据库

Django 将大部分与项目相关的信息都存储在数据库中,因此我们需要创建一个供Django使用的数据库

配置mysql数据库


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tlcb',
'USER': 'root',
'PASSWORD': '1234567',
'HOST': '192.168.137.3',
'PORT': '3306',
}
}


node2:/django/mysite/learning_log#python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
node2:/django/mysite/learning_log#

18.1.8 创建应用:


django-admin.py startproject learning_log

希望本文所述对大家基于Django框架的Python程序设计有所帮助。

来源:https://blog.csdn.net/zhaoyangjian724/article/details/95637947

标签:django,创建应用
0
投稿

猜你喜欢

  • SQLMAP插件tamper编写与使用详解

    2024-01-14 02:13:08
  • 用python删除文件夹中的重复图片(图片去重)

    2021-07-23 22:42:36
  • MySQL 5.7及8.0版本数据库的root密码遗忘的解决方法

    2024-01-19 01:40:37
  • 使用jQuery.form.js/springmvc框架实现文件上传功能

    2024-04-09 19:46:12
  • vue单页面在微信下只能分享落地页的解决方案

    2024-05-09 10:52:19
  • Python实现敲击木鱼积累功德小项目

    2021-02-11 05:29:03
  • 使用Python opencv实现视频与图片的相互转换

    2022-03-04 15:20:31
  • Python venv虚拟环境配置过程解析

    2021-11-30 20:21:48
  • JS+DIV实现拖动效果

    2023-07-02 05:19:37
  • python3实现从kafka获取数据,并解析为json格式,写入到mysql中

    2023-06-12 21:30:21
  • python 实现在Excel末尾增加新行

    2023-11-26 09:27:52
  • 详解Python3中setuptools、Pip安装教程

    2023-12-30 11:49:40
  • MySQL利用procedure analyse()函数优化表结构

    2024-01-17 14:51:00
  • Python数据可视化 pyecharts实现各种统计图表过程详解

    2022-04-08 17:28:37
  • pycharm激活方法到2099年(激活流程)

    2022-11-17 05:45:35
  • Python学习小技巧之列表项的排序

    2022-03-31 12:06:12
  • javascript定时变换图片实例代码

    2024-04-17 10:24:14
  • python静态web服务器实现方法及代码详解

    2023-01-13 17:17:12
  • Python实现并行抓取整站40万条房价数据(可更换抓取城市)

    2021-09-24 10:56:43
  • mysql5.7及mysql 8.0版本修改root密码的方法小结

    2024-01-28 17:09:31
  • asp之家 网络编程 m.aspxhome.com