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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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程序 - hgdfr 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修改一下: