您好,欢迎光临本网站![请登录][注册会员]  
文件名称: django 2.0 docoment for beginner as pdf format
  所属分类: 网页制作
  开发工具:
  文件大小: 480kb
  下载次数: 0
  上传时间: 2019-01-12
  提 供 者: andy****
 详细说明:document for django 2.0 as a pdf document for begginner. including 7 examples with difficulty increasing more and moreSecurity overview Disclosed security issues in Diango Clickjacking protection Cross Site Request Forgery protection cryptographIC SIgning Security Middleware Internationalization and localizational Django offers a robust internationalization and localization framework to assist you in the development of applications for multiple languages and word regions Overview Internationalization Localization Localized Web UI formatting and form input Lime zones Performance and optimizationg There are a variety of techniques and tools that can help get your code running more efficiently -faster, and using fewer system resources Performance and optimization overview Geographic framework Geo Diango intends to be a world-class geographic Web framework. Its goal is to make it as easy as possible to build Gis Web applications and harness the power of spatially enabled data Common Web application tools Django offers multiple tools commonly needed in the development of Web applications Authentication: Overview Using the authentication system Password management customizing authentication API Reference Caching Logging Sending emails tion feeds (Rss/Atom Pagination Messages framework Serialization Sessions Sitemaps Static files management Data validation Other core functionalities Learn about some other core functionalities of the django framework: Conditional content processing Content types and generic relations Flatpages ● Redirects Signals System check framework The sites framework Unicode in Django The Django open-source project l Learn about the development process for the Django project itself and about how you can contribute Community: How to get involved The release process Team organization The Diango source code repository Security policies Mailing lists Design philosophies: Overview Documentation: About this documentation Third-party distributions: Overview Django over time: API stability Release notes and upgrading instructions Deprecation Timeline Django at a glance Because Django was developed in a fast-paced newsroom environment, it was designed to make common Web- development tasks fast and easy. Here's an informal overview of how to write a database-driven Web app with Django The goal of this document is to give you enough technical specifics to understand how Django works, but this isnt intended to be a tutorial or reference -but we ve got both! When you' re ready to start a project, you can start with the tutorial or dive right into more detailed documentation Design your models Although you can use Django without a database, it comes with an object-relational mapper in which you describe your database layout in Python code The data-model syntax offers many rich ways of representing your models-so far, it's been solving many years worth of database-schema problems. Here's a quick example mysite/news/models. py from django db import models class Reporter(models Model) full name= models. CharField (max_ length=70) def str (self return self. full name class article(models Model) pub date= models. Date Fieldo headline models CharField(max length=200) content= models. TextFieldo reporter models ForeignKey(Reporter, on delete=models. CASCADE) def_str_(self) return self. headline Install it I Next, run the django command-line utility to create the database tables automatically S python manage. py migrate The migrate command looks at all your available models and creates tables in your database for whichever tables don' t already exist, as well as optionally providing much richer schema control Enjoy the free APll With that, you',ve got a free, and rich, Python aPi to access your data. the aPl is created on the fly, no code generation necessary Import the models we created from our"news"app >> from news. models import Article, Reporter No reporters are in the system yo >> Reporter objects. allo >>r= Reporter(full name=John Smith") Save the object into the database. You have to call save( explicitly Now it has an ID Now the new reporter is in the database ts allo ]> Fields are represented as attributes on the Python object John Smith' Django provides a rich database lookup aPI >>> Reporter. objectsget(id=1) >> Reporterobjects get(full_name startswith=John) >>>Reporter. objects. get(full name contains=mith) >> Reporter objects. get(id=2) Traceback(most recent call last Does notExist: Reporter matching query does not exist Create an article >>>from datetime import date >>>a= Article(pub date=date. today o, headline=Django is cool content-Yeah.', reporter-r) >>>a save #t Now the article is in the database >> Article objects. allo ]> article objects get aPI access to related Reporter objects r= areporter >>>r full name John smith And vice versa: Reporter objects get aPi access to article objects >>>rarticle set allo ]> The aPI follows relationships as far as you need, performing efficient JoiNs for you behind the scenes This finds all articles by a reporter whose name starts with"John >> Article objects. filter(reporter full_name starts with=John) ]> change an object by altering its attributes and calling save >>>r full name= Billy Goat >>>rsave Delete an object with delete >>>rdelete A dynamic admin interface: it's not just scaffolding-it's the whole houses Once your models are defined, Django can automatically create a professional, production ready administrative interface-a website that lets authenticated users add, change and delete objects. It's as easy as registering your model in the admin site mysite/news/models.py from django db import models class article(models Model pub date models Date Fieldo headline= models char Field (max length=200) content models. TextFieldo reporter =models. ForeignKey(Reporter, on_delete=models. CASCADE) mysite/news/admin . py from django. contrib import admin from. import models admin. site. register(models. article The philosophy here is that your site is edited by a staff, or a client, or maybe just you - and you don' t want to have to deal with creating backend interfaces just to manage content One typical workflow in creating Django apps is to create models and get the admin sites up and running as fast as possible, so your staff (or clients) can start populating data. Then, develop the way data is presented to the public Design your URLSII A clean, elegant URL scheme is an important detail in a high-quality Web application Django encourages beautiful URL design and doesn 't put any cruft in URLS, like php or. asp To design URLS for an app, you create a Python module called a URLconf. a table of contents for your app, it contains a simple mapping between URL patterns and Python callback functions. URLconfs also serve to decouple URLS from Python code Here's what a URLconf might look like for the Reporter/Article example above nysiteinews/urIs.py from django. urls import path from. import views urlpatterns path(articles//, views. year_archive) path ('articles///, views. month_archive), path('articles////,, views. article detail The code above maps URL paths to Python callback functions ("views"). The path strings use parameter tags to capture"values from the URLs. When a user requests a page, Django runs through each path, in order, and stops at the first one that matches the requested URL. (If none of them matches, Django calls a special-case 404 view This is blazingly fast, because the paths are compiled into regular expressions at load time Once one of the URL patterns matches, Django calls the given view, which is a Python function. Each view gets passed a request object -which contains request metadata -and the values captured in the pattern For example, if a user requested the url "/articles /2005/05/39323/,, Django would call the function news. views. article_detail(request, year=2005, month=5, pk=39323 Write your viewsil Each view is responsible for doing one of two things Returning an HttpresponSe object cantaining the content for the requested page or raising an exception such as Http404. The rest is up to you Generally, a view retrieves data according to the parameters, loads a template and renders the template with the retrieved data heres an example view for year archive from above mysIte newS/lews. py from django. shortcuts import render from, models import Article def year archive(request, year: a list= Article objects. filter(pub date year=year) context= year: year, 'article list: a list return render(request, news /year archive. html, context) This example uses Django's template system, which has several powerful features but strives to stay simple enough for non-programmers to use Design your templates The code above loads the news/year archive. html template Django has a template search path, which allows you to minimize redundancy among templates. In your django settings, you specify a list of directories to check for templates with DIRS. If a template doesnt exist in the first directory, it checks the second, and so on Let's say the news/year_archive. html template was found. Here's what that might look like mysite/news/templates/news/year_archive. html t% extends"base. html"%) f% block title %Articles for R year H% endblock %1 f%block content %1

Articles for i year

t% for article in article_ list% f article headline

By article reporter. full_name

Published article pub_date]date: "Fi,Y"]

[% endfor %j endblock % Variables are surrounded by double-curly braces. &l article headline means " output the value of the article s headline attribute " But dots aren't used only for attribute lookup. they also can do dictionary -key lookup, index lookup and function calls Note if article pub_dateldate Fj, Y"1 uses a Unix-style "pipe"(the" character). This is called a template filter, and it's a way to filter the value of a variable. In this case, the date filter formats a Python datetime object in the given format(as found in PHP's date function. You can chain together as many filters as you' d like. You can write custom template filters. You can write custom template tags, which run custom Python code behind the scenes Finally, Django uses the concept of"template inheritance". That's what the 1% extends"base. html"%)does. It means First load the template calledbase', which has defined a bunch of blocks, and fill the blocks with the following blocks. "In short, that lets you dramatically cut down on redundancy in templates: each template has to define only what's unique to that template Here's what the "base. html template, including the use of static files, might look like mysite/templates/base. h 9 load static % f% block title %H% endblock %]</tit </head> <body> <img src=t% static "images/sitelogo png"%]"alt="LOgo"/> block content %H% endblock </body> </html> Simplistically, it defines the look-and-feel of the site(with the site's logo), and provides holes"for child templates to fill. This makes a site redesign as easy as changing a single file -the base template It also lets you create multiple versions of a site, with different base templates, while reusing child templates Django's creators have used this technique to create strikingly different mobile versions of sites- simply by creating a new base template Note that you don ' t have to use Django' s template system if you prefer another system while django's template system is particularly well-integrated with Django's model layer, nothing forces you to use it. For that matter, you don' t have to use Django's database APl, either. You can use another database abstraction layer, you can read XML files, you can read files off disk, or anything you want. Each piece of Django- models, views, templates -is decoupled from the next This is just the surfaced This has been only a quick overview of Django's functionality Some more useful features A caching framework that integrates with memcached or other backends A syndication framework that makes creating RSS and Atom feeds as easy as writing a small Python class More sexy automatically-generated admin features -this overview barely scratched the surface The next obvious steps are for you to download Diango, read the tutorial and join the community. Thanks for your interest Quick install guides Before you can use Django, you'll need to get it installed We have a complete installation guide that covers all the possibilities; this guide will guide you to a simple, minimal installation that'll work while you walk through the introduction Install Python I Being a Python Web framework, Django requires Python. See What Python version can l use with Diango? for details. Python includes a lightweight database called SQLite so you wont need to set up a database just yet GetthelatestversionofPythonathttps://www.python.org/downloadslorwithyouroperatingsystemspackage manager. You can verify that Python is installed by typing python from your shell; you should see something like Python 3.4.X [GCC4×] on linux Type"holp","copyright", "credits"or"license"for more information Set up a database This step is only necessary if you' d like to work with a "large" database engine like PostgreSQL, MysQL, or Oracle To install such a database. consult the database installation information Remove any old versions of Django If you are upgrading your installation of Django from a previous version, you will need to uninstall the old Diango version before installing the new version Install Django You've got three easy options to install Django Install an official release. This is the best approach for most users Install a version of Django provided by your operating system distribution Install the latest development version. This option is for enthusiasts who want the latest-and-greatest features and aren't afraid of running brand new code. You might encounter new bugs in the development version but reporting them helps the development of Django. Also, releases of third-party packages are less likely to be compatible with the development version than with the latest stable releas Always refer to the documentation that corresponds to the version of Django you re using If you do either of the first two steps, keep an eye out for parts of the documentation marked new in development version. That phrase flags features that are only available in development versions of Django, and they likely wont work with an official release Verifying To verify that Django can be seen by python, type python from your shell. then at the python prompt, try to import Django</B> </div> <div class="title2"><div class="title_more">(系统自动生成,下载前可以参看下载内容)</div><h2>下载文件列表</h2></div> <div class="font12"> </div> <div id="show_memo" class="show_info"> <div class="title2"><h2>相关说明</h2></div> <div class="box_content"> <ul> <li>本站资源为会员上传分享交流与学习,如有侵犯您的权益,<a href="/about/contact.php" target="_blank">请联系我们删除</a>.</li> <li>本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行<a href="https://www.baidu.com" target="_blank">百度</a>。</li> <li class="red">本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用<a href="http://rarlab.com/download.htm" target="_blank">WinRAR最新版</a>进行解压.</li> <li>如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录<a href="/user/log.php?type=5" target="_blank">反馈给我们</a>.</li> <li>下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录<a href="/user/log.php?type=5" target="_blank">反馈给我们</a>,经确认后退回积分.</li> <li>如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.</li> </ul> </div> </div> <div class="detail_line">  <B>相关搜索</B>: <a href="/search.php?keyword=django2.0docomentforbeginneraspdfformat" target="_blank">django2.0docomentforbeginneraspdfformat</a> </div> <form name="search" action="/search.php" method="get"> <div class="detail_line">  输入关键字,在本站1000多万海量源码库中尽情搜索:<INPUT maxLength="50" size="20" name="keyword" value=""> <input type="submit" value="搜 索" name=_search2>  </div> </form> </div><!-- Show end. --> </div> <div id="sidebar" class="fr"><!-- Left begin --> <!--频道分类开始--> <div class="box"> <div class="title"><h2>下载资源分类</h2></div> <div class="channel_sort"> <h3><a href="/21/">移动开发</a></h3> <h3><a href="/16/">开发技术</a></h3> <h3><a href="/15/">课程资源</a></h3> <h3><a href="/19/">网络技术</a></h3> <h3><a href="/12/">操作系统</a></h3> <h3><a href="/10/">安全技术</a></h3> <h3><a href="/18/">数据库</a></h3> <h3><a href="/14/">行业</a></h3> <h3><a href="/13/">服务器应用</a></h3> <h3><a href="/11/">存储</a></h3> <h3><a href="/20/">信息化</a></h3> <h3><a href="/17/">考试认证</a></h3> <h3><a href="/22/">云计算</a></h3> <h3><a href="/23/">大数据</a></h3> <h3><a href="/24/">跨平台</a></h3> <h3><a href="/25/">音视频</a></h3> <h3><a href="/26/">游戏开发</a></h3> <h3><a href="/27/">人工智能</a></h3> <h3><a href="/28/">区块链</a></h3> </div> </div> <div class="box"> <div class="title"><h2>资源分类</h2></div> <div class="channel_sort"> <h3><a href="/1501/">3G/移动开发</a></h3> <h3><a href="/1502/">C/C++</a></h3> <h3><a href="/1503/">Java</a></h3> <h3><a href="/1504/">.Net</a></h3> <h3><a href="/1505/">PHP</a></h3> <h3><a href="/1506/">嵌入式</a></h3> <h3><a href="/1507/">软件测试</a></h3> <h3><a href="/1508/">数据库</a></h3> <h3><a href="/1509/">网络管理</a></h3> <h3><a href="/1510/">网页制作</a></h3> <h3><a href="/1511/">游戏开发</a></h3> <h3><a href="/1512/">专业指导</a></h3> <h3><a href="/1513/">讲义</a></h3> <h3><a href="//"></a></h3> </div> </div> <div class="box"><!--本站统计开始--> <div class="title"><h2>本站统计</h2></div> <UL class="info_ul"> <LI>资源总数:<b>630</b>万个</LI> <LI>资源大小:<b>15</b>TB</LI> <LI>今日更新:468个</LI> <LI>注册人数:225万</LI> <LI>今日注册:838</LI> </UL> </div><!--本站统计结束--> <div class="box"><!--Intro begin.--> <div class="title"><h2><a href="/register.php">加入“点数信息”会员</a></h2></div> <div class="box_content">   “点数信息”是专业的,大型的源码,编程资源等搜索,交换平台,旨在帮助软件开发人员提供源码,编程资源下载,技术交流等服务!目前源码资源大小已超过8TB。<br>   超值价格,购买下载积分,即时到帐,无需等待马上可以下载你所需的资料。无限期使用,一次购买越多越优惠!<br> </div> </div><!--Intro end.--> <div class="box"><!--Intro begin.--> <div class="title"><h2><a href="/register.php">免费获取积分</a></h2></div> <div class="box_content">   免费获得积分的途径是通过会员下载您上传的资料,您的帐户即增加积分。<br>   立即上传资料,越多越好,被搜索到的机会越大!越早上传越早得积分,下载次数越多,您的积分越多。<br> </div> </div><!--Intro end.--> <!--合作伙伴开始--> <div class="box"> <div class="title1"><h2>合作伙伴</h2></div> <!--推荐商家具体内容开始--> <div class="channel_friend"><!--最多七个字--> <ul> <li><a href="http://www.codeproject.com/" target="_blank">CodeProject</a></li> <li><a href="http://www.dssz.com/" target="_blank">搜珍网</a></li> <li><a href="http://www.5177517.com/" target="_blank">建筑工程网</a></li> <li><a href="http://www.csdn.net/" target="_blank">CSDN.net</a></li> <li><a href="http://www.5imomo.com/" target="_blank">建筑资料网</a></li> </ul> </div> </div> </div><!-- Left end --> </div> <div id="footer"> <div class="content"> <div class="cr"> 客服QQ:6133080 <a href="mailto:info@dssz.net">联系站长</a> · <a href="/about/guestbook.php" rel="nofollow">版权投诉</a> · <a href="/about/guestbook.php" rel="nofollow">网站修改建议</a> </div> <div class="cl"> © 1999-2048 <a href="https://www.dssz.net" target="_blank"><font color=red>dssz.net</font></a> <a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备11031372号</a> </div> </div> </div> </body> </html> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); //--> </SCRIPT>