django框架創(chuàng)建應用操作示例
本文實例講述了django框架創(chuàng)建應用操作。分享給大家供大家參考,具體如下:
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 中創(chuàng)建項目:
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 創(chuàng)建數(shù)據庫
Django 將大部分與項目相關的信息都存儲在數(shù)據庫中,因此我們需要創(chuàng)建一個供Django使用的數(shù)據庫
配置mysql數(shù)據庫
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 創(chuàng)建應用:
django-admin.py startproject learning_log
希望本文所述對大家基于Django框架的Python程序設計有所幫助。
- python Django 創(chuàng)建應用過程圖示詳解
- python使用Pycharm創(chuàng)建一個Django項目
- 使用PyCharm創(chuàng)建Django項目及基本配置詳解
- Django在win10下的安裝并創(chuàng)建工程
- Django中ORM表的創(chuàng)建和增刪改查方法示例
- 在Python的Django框架中創(chuàng)建語言文件
- 在Django中創(chuàng)建動態(tài)視圖的教程
- 在Python的Django框架中創(chuàng)建和使用模版
- 詳解在Python的Django框架中創(chuàng)建模板庫的方法
- 使用python搭建Django應用程序步驟及版本沖突問題解決
- 在Django框架中運行Python應用全攻略
- Docker部署Django應用的示例
相關文章
Python對Excel兩列數(shù)據進行運算的示例代碼
本文介紹了如何使用Python中的pandas庫對Excel表格中的兩列數(shù)據進行運算,并提供了詳細的代碼示例,感興趣的朋友跟隨小編一起看看吧2024-04-04詳解python的sorted函數(shù)對字典按key排序和按value排序
這篇文章主要介紹了詳解python的sorted函數(shù)對字典按key排序和按value排序,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-08-08對python中assert、isinstance的用法詳解
今天小編就為的就分享一篇對python中assert、isinstance的用法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11Python face_recognition實現(xiàn)AI識別圖片中的人物
最近碰到了照片識別的場景,正好使用了face_recognition項目,給大家分享分享。face_recognition項目能做的很多,人臉檢測功能也是有的,是一個比較成熟的項目。感興趣的可以了解一下2022-01-01下載與當前Chrome對應的chromedriver.exe(用于python+selenium)
這篇文章主要介紹了下載與當前Chrome對應的chromedriver.exe(用于python+selenium),本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2020-01-01Pyqt清空某一個QTreeewidgetItem下的所有分支方法
今天小編就為大家分享一篇Pyqt清空某一個QTreeewidgetItem下的所有分支方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06