惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
V
Visual Studio Blog
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
IT之家
IT之家
博客园_首页
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - Franky
雷峰网
雷峰网
罗磊的独立博客
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
The Cloudflare Blog
T
Tailwind CSS Blog
B
Blog RSS Feed
H
Help Net Security
T
The Blog of Author Tim Ferriss
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
P
Palo Alto Networks Blog
I
Intezer
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
S
Securelist
J
Java Code Geeks
V
V2EX
Y
Y Combinator Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
Forbes - Security
Forbes - Security
Google Online Security Blog
Google Online Security Blog
Help Net Security
Help Net Security
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
SecWiki News
SecWiki News
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
N
News and Events Feed by Topic

博客园 - hgdfr

Django1.5内置的用户认证系统介绍(之五)在admin后台管理用户 --by hillfree Django1.5内置的用户认证系统介绍(之四)Authentication in Web requests --by hillfree Django1.5内置的用户认证系统介绍(之三)权限与授权--by hillfree Django1.5内置的用户认证系统介绍(之二)使用User对象--by hillfree Django1.5内置的用户认证系统介绍(之一)--by hillfree Django REST Framework Tutorial 5:关系与超链接API(中文版教程)by hillfree Django REST Framework Tutorial 4:认证与权限(中文版教程)by hillfree Django REST Framework Tutorial 3:基于类的Views(中文版教程)by hillfree Django1.5中设置静态目录的简要说明 参照《鲜活的数据:数据可视化指南》第2章:抓取网页数据(历史天气记录)的Python程序 Python3.3中如何产生伪随机数 《鲜活的数据:数据可视化指南》第2章 收集数据 Python3.3源码 CSCW领域的“老”词和“新”词 FOAF简介和朋友圈子 Class Library类型的工程难道不能用app.config? 配置文件中的DataDirectory在那里设置? 自己写的类需要重写ToString(), HashCode(), Equal()吗? 注释中如果出现尖括号怎么办?“<” - hgdfr - 博客园 Access Control Issues 有关访问控制
Django1.5+Python3.3下groundwork的使用
hgdfr · 2013-03-22 · via 博客园 - hgdfr

因为要学习“心内求法”关于Django的教程,其中提到了groundwork的应用,因为django1.5(应该说1.4及以上)目录结构生成较之前发生了变化,再加上python3.x的语法也较python2.7有所差异,所以为了使用groundwork,还需要做一些适应性的修改。记录如下,作为备忘:

(1) 下载groundwork:
在https://github.com/freetstar/django-groundwork下载;

(2) 安装groundwork,修改groundwork.py
解压后,直接把django-groundwork目录拷贝到项目根目录下;
需要把django-groundwork/management/commands/groundwork.py修改一下:
把之前的from placeholders import *,改为from .placeholders import *。增加了一个"."。
把所有print语句改为print()函数方式。

(3) 完成Model定义后,调用groundwork生成view,form,template。
输入>manage.py groundwork <app_name> <model> # 假设app_name为du,model为book

(4) 把项目根目录下/<project_name>/templates/下的<app_name>目录和base.html,都拷贝到项目同名目录下的templates目录下,即/<project_name>/<project_name>/templates/下。并删去之前的templates目录。

(5) 在对应的templates下的<app_name>目录下,找到list_<model>.html。搜索“{% url”,Django1.5中,正确的格式为{% url 'path.to.some_view' v1 v2 %}。所以要把所有类似与:{% url du.views.view_book item.id %},都改为{% url "du.views.view_book" item.id %},即view部分都要加上引号。

(6) 此时urls.py已经加入了对应urlpatterns,可以去看看或者梳理下。

(7) 在app目录下,打开views.py,把之前的import改为如下:
  from django.conf.urls import *
  from .views import * # 同目录下需要加"."

(8) 此时运行服务器,就可以在http://127.0.0.1:8000/du/book/list/下看到简单的页面了。
(9) 在此之前,还需要把django-groundwork/management/commands/groundwork.py修改一下: