欢迎来到天天文库
浏览记录
ID:34722675
大小:259.18 KB
页数:28页
时间:2019-03-10
《django1.5官方入门教程第1部分》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、第一个Djangoapp,第1部分让我们从例子开始学习.Throughoutthistutorial,we’llwalkyouthroughthecreationofabasicpollapplication.通过整个教程,我们会从头至尾向你介绍怎样创建一个基本的投票程序。。It’llconsistoftwoparts:这个应用程序这将包括两部分:§Apublicsitethatletspeopleviewpollsandvoteinthem.一个能够让用户查看投票选项并进行投票的前台§Anadminsitethatlets
2、youadd,changeanddeletepolls.一个能够进行投票管理的后台We’llassumeyouhave Djangoinstalled already.YoucantellDjangoisinstalledandwhichversionbyrunningthefollowingcommand: 我们假设你已经安装了Django。通过下面的命令,你可以得到Django的版本。(译者注:Windows操作系统,首先将python的安装路径添加到系统路径中,然后在cmd中运行这个命令。)python-c"impor
3、tdjango;print(django.get_version())"YoushouldseeeithertheversionofyourDjangoinstallationoranerrortelling“Nomodulenameddjango”.Checkalsothattheversionnumbermatchestheversionofthistutorial.Iftheydon’tmatch,youcanrefertothetutorialforyourversionofDjangoorupdateDjangot
4、othenewestversion. 你应该看Django版本号,或者是一条错误信息“django模块没有定义”。请确定你的版本号与本教程的一致。如果不一致,查看相应版本的教程,或把Django更新到本版本。See HowtoinstallDjango foradviceonhowtoremoveolderversionsofDjangoandinstallanewerone. 请参阅如何卸载和安装Django。Wheretogethelp:Ifyou’rehavingtroublegoingthroughthistutor
5、ial,pleasepostamessageto django-users ordropby #djangoonirc.freenode.net tochatwithotherDjangouserswhomightbeabletohelp.Creatingaproject创建项目IfthisisyourfirsttimeusingDjango,you’llhavetotakecareofsomeinitialsetup.Namely,you’llneedtoauto-generatesomecodethatestablish
6、esaDjango project –acollectionofsettingsforaninstanceofDjango,includingdatabaseconfiguration,Django-specificoptionsandapplication-specificsettings. 如果这是你第一次使用Django,你需要注意一下初始化设置。也就是说,你需要自动创建一些Django项目初始化的代码——包括数据库设置、Django特性设置以及程序特性设置。Fromthecommandline, cd intoadi
7、rectorywhereyou’dliketostoreyourcode,thenrunthefollowingcommand: 在命令行界面下,进入到你放置代码的目录中,执行命令django-admin.pystartprojectmysite。django-admin.pystartprojectmysiteThiswillcreatea mysite directoryinyourcurrentdirectory.Ifitdidn’twork,see Problemsrunningdjango-admin.py. 这将
8、在当前目录下创建一个mysite目录,如果失败,请查看有关运行django-admin.py的内容。NoteYou’llneedtoavoidnamingprojectsafterbuilt-inPythonorDjangocomponents.Inparticular,thismeans
此文档下载收益归作者所有