资讯专栏INFORMATION COLUMN

# 0x00 django -- creating your first django projec

fuchenxuan / 3240人阅读

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




    
    Hello Django


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

相关文章

  • #date:2017.07.19 django app, Part 2

    摘要:这篇教程从教程,我们会配置自己的数据库,创造你的第一个模型,开始一个快捷的自动生成管理员站点。项目是一个特性网站的相关配置和应用的集合。 Writing your first django app, part 2 this tutorial begins where Tutorial 1 left off.Well setup the database, create your fir...

    MartinHan 评论0 收藏0
  • python第三方库之Django学习笔记二

    摘要:上一节项目框架已经搭建完毕,现在开始连接数据库,创建数据库设置默认安装了数据库打开文件数据库引擎数据库的名字小贴士如果你选择,数据库是以文件的形式生成,要设置成绝对路径创建表结构创建模型激活模型执行命令执行成功后目录结构如下图 上一节项目框架已经搭建完毕,现在开始连接数据库,创建model 1、数据库设置python默认安装了sqlite数据库 打开文件:dayang/settings...

    Java3y 评论0 收藏0

发表评论

0条评论

fuchenxuan

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<