zoukankan      html  css  js  c++  java
  • python框架-Django创建项目

    创建项目

    django-admin startproject douban//创建project
    cd douban
    python manage.py startapp books//创建app项目

    配置文件

    在douban文件夹下
    1.vim books/views.py//写入页面程序

    # -*- coding: utf-8 -*-
    from __future__ import unicode_literals
    
    from django.shortcuts import render
    
    # Create your views here.
    from django.http import HttpResponse
    
    def hello(request):
        return HttpResponse("hello douban!!")
    

    2.vim douban/urls.py//修改路由

    from django.conf.urls import url
    from django.contrib import admin
    
    from books import views
    
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        url(r'^hello/douban/$',views.hello),
    ]
    

    3.vim douban/settings.py//修改基本设置

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'books'//添加books项
    ]
    

    4.运行python manage.py runserver
    在浏览器访问http://127.0.0.1:8000/hello/douban/
    返回hello douban!!!即可

  • 相关阅读:
    Linux終端一行命令发送邮件
    团队冲刺2.4
    团队冲刺2.3
    团队冲刺2.2
    找水王
    评价win10自带输入法——微软拼音输入法
    梦断代码阅读笔记01
    团队冲刺2.1
    第十三周总结
    第十二周总结
  • 原文地址:https://www.cnblogs.com/zhuzq/p/9534746.html
Copyright © 2011-2022 走看看