Django项目(pycharm)

一、创建环境

#在anaconda里写如下命令
conda create -n web python=3.8
conda activate web

#安装相应Django
pip install Django

#安装你的代码需要的其他库
conda install ...

二、创建Django项目

打开pycharm -> file ->new project

 创建完成后文件夹内容如下

菜单栏 tool -> run manage.py Task -> 输入startapp calculation(calculation自己定义名称;会报错没有os包,找到相应位置在文件最开始加上import os就可以了)

 在根目录下新建static文件夹,装静态文件(如图片,CSS,JS;要在static文件夹下再另外设置图片、CSS、JS的文件夹)

三、写项目内容

在写Django项目时会用到如下几个文件

url.py连接网页以及其用到的函数

view.py编辑该网页用到的函数

templates/存放网页的.html文件

static/存放网页的静态文件

四、运行

菜单栏 tool -> run manage.py Task -> 输入runserver  -> 点击连接

五、上传代码到git

1.gitee创建仓库

 2.写.gitignore文件(项目目录下存放)

# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# ---> macOS
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# ---> VisualStudioCode
.vscode/*
.vscode/settings.json
*.code-workspace

# local config
local_config.py

# log
*.log.*

# .env
! default.env

# .idea 配置文件
.idea/

3.命令上传文件

#配置
git config --global user.name "***"
git config --global user.email "**********@qq.com"

#建立联系
cd optimization/
git init
git remote add origin https://gitee.com/***/optimization.git

#上传代码
git add .
git commit -m 'init'
git push origin master

4.服务器连接git上代码

#安装git
yum install git -y

#在你需要的目录下克隆
git clone https://gitee.com/xie-jiayang/optimization

#项目更新,cd进入项目目录
git pull origin master

六、项目部署到服务器

参考django部署服务器

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值