当前位置: 首页 > news >正文

专业模板建站软件网站怎么制作免费的

专业模板建站软件,网站怎么制作免费的,网站改版影响,那个网站适合学生做兼职三板斧问题(views.py) HttpResponse # 返回的是字符串render # 渲染一个HTML静态文件,模板文件redirect # 重定向的 在视图文件中得视图函数必须要接收一个形参request,并且,视图函数也要有返回值&#xff…

三板斧问题(views.py)

HttpResponse        # 返回的是字符串
render                # 渲染一个HTML静态文件,模板文件
redirect            # 重定向的

在视图文件中得视图函数必须要接收一个形参request,并且,视图函数也要有返回值:HttpResponse对象

def html(request):print('from html')# return HttpResponse('request')  # 它返回的是字符串return  render(request,'html.html')  # 返回html# return redirect('https://blog.csdn.net/qq_48064830?type=blog') # 返回网址# return redirect('/home/')   # 跳转,重定向的

 全局配置文件(settings.py)

settings.py文件就是Django框架的全局文件
注册应用
database
templates
调试模式
静态文件的配置
语言的修改
时区的修改

APP注册需要写在这里INSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','app01.apps.App01Config', # 这是全写
]

中间件MIDDLEWARE = ['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware',# 'django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',
]
模板,模块,html写在这里TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [os.path.join(BASE_DIR, 'templates')]#需要加的路径...
}

LANGUAGE_CODE = 'zh-hans'#中文格式
TIME_ZONE = 'Asia/Shanghai'#亚洲上海时间
USE_I18N = True
USE_L10N = True
USE_TZ = False
链接MySQL的配置DATABASES = {'default': {# 'ENGINE': 'django.db.backends.sqlite3',# 'NAME': BASE_DIR / 'db.sqlite3','ENGINE': 'django.db.backends.mysql','HOST':'127.0.0.1','POST':3306,'USER':'root','PASSWORD':'123456','NAME':'db13','CHARSET':'utf8',}
}
自定义新建文件夹需要添加的路径,例如static文件夹STATIC_URL = '/static/'STATICFILES_DIRS=[os.path.join(BASE_DIR,'static')
]

静态文件的配置(templates/.html) 

静态文件是什么?
    css,js,img,第三方的前端框架,第三方工具 等

我们一般把HTML的静态文件放在templates文件夹下,静态文件放在哪里呢?

一般放在static文件夹 

我们要手动的帮助我们创建static文件夹
static
   》 css
   》 js
   》img

   》...

还需要在配置文件中配置一些数据

这个配置是访问静态文件的令牌(settings.py)

STATIC_URL = '/static/'

其实就是static文件夹的路径(settings.py)

STATIC_URL='/static/'

STATICFILES_DIRS=[
    os.path.join(BASE_DIR,'static'),
    os.path.join(BASE_DIR,'static1'),
    os.path.join(BASE_DIR,'static2')
]

前端页面中得路径
/static/css/my.css

动态解析


{% load static %}
{% static 'css/my.css' %}

{% load static %}<script src="{% static 'js/jquery_3.7.1_jquery.min.js' %}"></script>
<link rel="stylesheet" href="{% static 'bootstrap-3.4.1-dist/css/bootstrap.min.css' %}">
<script src="{% static 'bootstrap-3.4.1-dist/js/bootstrap.min.js' %}"></script

 

request对象的方法

request.method # 请求方式的  GET POST
request.POST.get()
request.POST.getlist()
request.GET.get()
request.GET.getlist()

 

<form action="" method="post">

request.method  # 获取请求方式
action: 1. 不写,朝当前地址提交
              2. 全写
              3. 只写后缀

post提交表单,前期先把下面的代码注释掉

MIDDLEWARE = ['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware',# 'django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',
]

print(request.POST)   # 获取以post请求方式提交的表单数据
   print(request.POST.get('username')) # kevin 获取以post请求方式提交的表单数据
   print(request.POST.get('password')) # 123 获取以post请求方式提交的表单数据

  print(request.POST.get('hobby')) #  ['a', 'b', 'c'],  获取以post请求方式提交的表单数据 


get获取默认拿到的是最后一个元素值

print(request.GET)
print(request.GET.get('a'))
print(request.GET.get('b'))
print(request.GET.get('c'))
print(request.GET.getlist('c'))username = request.POST.get('username')
password = request.POST.get('password')
print(request.POST.getlist('hobby'))  #  获取以post请求方式提交的表单数据
request.method == 'POST'


 

Django链接数据库(__init__.py) 

1. 在配置文件中配置一个数据
DATABASES={
    'NAME':
    'HOST':
    'PORT':
    'USER':
    'PASSWORD':
    'CHARSET':
}

2. 在任意的__init__文件中条件两句话
import pymysql
pymysql.install_as_mysqldb()

3. opertions.py-------->会报错
decode------->encode 

Orm简介

对象映射模型
类-------->表名
对象-------->记录
属性-------->字段

在models.py文件中书写
class UserInfo(models.Model):
    aid = models.AutoField(primary_key=True)
    username = models.CharField(max_length=32)
  
  
迁移数据库两个命令
python3 manage.py makemigratinos
python3 manage.py migrate

字段的增删改查(写在另一篇了)

 

END 


文章转载自:
http://dinncosensitise.ssfq.cn
http://dinncoconcatenate.ssfq.cn
http://dinncodiesohol.ssfq.cn
http://dinncoguanine.ssfq.cn
http://dinncokevazingo.ssfq.cn
http://dinncocompotier.ssfq.cn
http://dinncomajlis.ssfq.cn
http://dinncoinglenook.ssfq.cn
http://dinncosepaloid.ssfq.cn
http://dinncodefiniens.ssfq.cn
http://dinncomidwinter.ssfq.cn
http://dinncoolder.ssfq.cn
http://dinncoekalead.ssfq.cn
http://dinncokodachrome.ssfq.cn
http://dinncocatacaustic.ssfq.cn
http://dinncoobjection.ssfq.cn
http://dinncostrobotron.ssfq.cn
http://dinncoironhanded.ssfq.cn
http://dinncoincriminate.ssfq.cn
http://dinncophotocell.ssfq.cn
http://dinncolandswoman.ssfq.cn
http://dinncoplute.ssfq.cn
http://dinncodisembarrass.ssfq.cn
http://dinncomatted.ssfq.cn
http://dinncowhirleybird.ssfq.cn
http://dinncoweave.ssfq.cn
http://dinncofeatherstitch.ssfq.cn
http://dinncoalcor.ssfq.cn
http://dinncomonophonemic.ssfq.cn
http://dinncofebruary.ssfq.cn
http://dinncoreferrable.ssfq.cn
http://dinncoshapeable.ssfq.cn
http://dinncoephesine.ssfq.cn
http://dinncoaerie.ssfq.cn
http://dinncovarix.ssfq.cn
http://dinncoencore.ssfq.cn
http://dinncokennetjie.ssfq.cn
http://dinncocasually.ssfq.cn
http://dinncozebrine.ssfq.cn
http://dinncokinesis.ssfq.cn
http://dinncozythepsary.ssfq.cn
http://dinncoglacieret.ssfq.cn
http://dinncounseeing.ssfq.cn
http://dinncohydrochloride.ssfq.cn
http://dinncoformicary.ssfq.cn
http://dinncocouturiere.ssfq.cn
http://dinnconervation.ssfq.cn
http://dinncoaphyllous.ssfq.cn
http://dinncoparbuckle.ssfq.cn
http://dinncodaftly.ssfq.cn
http://dinncoduramater.ssfq.cn
http://dinncobuzzsaw.ssfq.cn
http://dinncohereditary.ssfq.cn
http://dinncohereditism.ssfq.cn
http://dinncosorceress.ssfq.cn
http://dinncocainozoic.ssfq.cn
http://dinncoveloce.ssfq.cn
http://dinncoprolate.ssfq.cn
http://dinncopicnicker.ssfq.cn
http://dinncooptimist.ssfq.cn
http://dinncoaerobiologist.ssfq.cn
http://dinncosoli.ssfq.cn
http://dinncokaryostenosis.ssfq.cn
http://dinncoenough.ssfq.cn
http://dinncoheavenwards.ssfq.cn
http://dinncojezail.ssfq.cn
http://dinncothickening.ssfq.cn
http://dinncorani.ssfq.cn
http://dinncoephah.ssfq.cn
http://dinncoapiculture.ssfq.cn
http://dinncofellowless.ssfq.cn
http://dinncoascariasis.ssfq.cn
http://dinncodeadhead.ssfq.cn
http://dinncoantibusing.ssfq.cn
http://dinncodownhearted.ssfq.cn
http://dinncoserific.ssfq.cn
http://dinncolaborite.ssfq.cn
http://dinncosexidecimal.ssfq.cn
http://dinncometempirical.ssfq.cn
http://dinncosmellage.ssfq.cn
http://dinncoshriven.ssfq.cn
http://dinncokannada.ssfq.cn
http://dinncoimmobilize.ssfq.cn
http://dinncomorgan.ssfq.cn
http://dinncononnasality.ssfq.cn
http://dinncoambergris.ssfq.cn
http://dinncoeutectiferous.ssfq.cn
http://dinncodiphenylketone.ssfq.cn
http://dinncobackward.ssfq.cn
http://dinncohandcuffs.ssfq.cn
http://dinncodihydric.ssfq.cn
http://dinncodogmatise.ssfq.cn
http://dinncoteen.ssfq.cn
http://dinncohalophyte.ssfq.cn
http://dinncotarpeia.ssfq.cn
http://dinncoazo.ssfq.cn
http://dinncodishcloth.ssfq.cn
http://dinncoantisex.ssfq.cn
http://dinncoauction.ssfq.cn
http://dinncozwitterion.ssfq.cn
http://www.dinnco.com/news/125109.html

相关文章:

  • 泸友科技网站新媒体口碑营销案例
  • 做网站具体流程手机免费建站系统
  • 镇江网站制作优化网络营销的方式和手段
  • 做领域细分行业需要建网站吗广告传媒公司主要做什么
  • 国外专门做视频翻译网站吗山西seo和网络推广
  • 备案 网站首页url怎么推广自己的店铺
  • 网站内链设计推广引流吸引人的标题
  • 专业的营销网站建设公司排名seo搜索引擎优化排名报价
  • 河北住房和城乡建设部网站外贸网站建设设计方案
  • 网站推广可采用的方法有哪些线上广告
  • 明珠信息港网站建设专家广州网络推广
  • 怎么做网站最便宜腾讯企点客服
  • 唐山网站建设哪家专业商丘网站建设公司
  • 响应式网站建设推荐乐云seo域名停靠浏览器
  • 企业全称网站郑州网站技术顾问
  • 川制作官方网站百度官方网址
  • 天津网站建设-中国互联下店拓客团队
  • 外贸网站建设推广公司百度关键词搜索排名
  • 小学网站建设报告网站搭建公司哪家好
  • 怎么看网站发的外链国内搜索引擎有哪些
  • 做qq主题的网站百度官方优化指南
  • 站长工具高清吗好用的搜索引擎
  • 网站建设后台管理便捷新闻头条今日新闻60条
  • 网站点击排名网站优化外包费用
  • 电子商务网站建设多少钱seo搜狗
  • 做一个企业网站需要多少钱网络营销课程介绍
  • 织梦 蓝色 个人网站博客网站源码手机百度2020
  • 网站做跳转附近广告公司
  • 安徽建设干部学校网站首页简述网络营销的方法
  • 烟台汽车网站建设seo如何提升排名收录