0x00 django -- creating your first django project
1.preparatory work
python3: we will use python 3.5 to develop this project
pycharm: install pycharm professional on your computer--->Pycharm downloads
linux: we will develop this project on linux
django: pip3 install django
2.use pycharm IDLE to start your project
open your pycharm and create a django project
you will get a project
3.modify the setting file ~/djangoCarl/settings.py
</>复制代码
ALLOWED_HOSTS = [
"127.0.0.1",
"www.exampleCarlBenjamin.com"
]
4.create the index.html ~/templates/index.html like that
</>复制代码
<span class="hljs-attr">Hello</span> <span class="hljs-string">Django</span>
Hello Django
5.modify your views ~/application/views.py like that
</>复制代码
# coding=utf-8
from django.shortcuts import render
# Create your views here.
def application(request):
return render(request, "index.html")
6.modify your urls ~/djangoCarl/urls.py like that
</>复制代码
from django.conf.urls import url
from django.contrib import admin
from application.views import application
urlpatterns = [
url(r"$", application, name="application"),
url(r"^admin/", admin.site.urls),
]
7.cd to your workspace and
</>复制代码
python3 manage.py runserver
8.You will see 127.0.0.1:8000
9.Now you complete your first project of django
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/38616.html
摘要:这篇教程从教程,我们会配置自己的数据库,创造你的第一个模型,开始一个快捷的自动生成管理员站点。项目是一个特性网站的相关配置和应用的集合。 Writing your first django app, part 2 this tutorial begins where Tutorial 1 left off.Well setup the database, create your fir...
摘要:上一节项目框架已经搭建完毕,现在开始连接数据库,创建数据库设置默认安装了数据库打开文件数据库引擎数据库的名字小贴士如果你选择,数据库是以文件的形式生成,要设置成绝对路径创建表结构创建模型激活模型执行命令执行成功后目录结构如下图 上一节项目框架已经搭建完毕,现在开始连接数据库,创建model 1、数据库设置python默认安装了sqlite数据库 打开文件:dayang/settings...
阅读 1678·2021-11-02 14:48
阅读 3779·2019-08-30 15:56
阅读 2844·2019-08-30 15:53
阅读 3282·2019-08-30 14:09
阅读 3195·2019-08-30 12:59
阅读 2928·2019-08-29 18:38
阅读 2782·2019-08-26 11:41
阅读 2351·2019-08-23 16:45