-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex4.html
More file actions
376 lines (334 loc) · 20.3 KB
/
index4.html
File metadata and controls
376 lines (334 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<link rel="short icon" href="http://softing.qiniudn.com/20140603011448867_easyicon_net_128.ico" type="image/x-ico">
<meta charset="utf-8">
<title>Dreaming</title>
<meta name="author" content="tulpar">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link href="/favicon.png" rel="icon"> -->
<link href="/theme/css/main.css" media="screen, projection"
rel="stylesheet" type="text/css">
<script src="/theme/js/modernizr-2.0.js"></script>
<script src="/theme/js/ender.js"></script>
<script src="/theme/js/octopress.js" type="text/javascript"></script>
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
</head>
<body>
<header role="banner"><hgroup>
<h1><a href="/">Dreaming</a></h1>
</hgroup></header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
</ul>
<ul class="main-navigation">
<li >
<a href="/category/it.html">It</a>
</li>
<li >
<a href="/category/life.html">Life</a>
</li>
</ul></nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title">
<a href="/ueditorzai-djangozhong-de-shi-yong.html">Ueditor在Django中的使用</a>
</h1>
<p class="meta"><time datetime="2014-06-14T00:00:00+08:00" pubdate>Sat 14 June 2014</time></p>
</header>
<div class="entry-content"><p>以前写过Ueditor在Django中的使用方法(虽然跟着上一个博客一起丢了),在此不赘述了。想学可以看看这位朋友的分享:
<a href="https://github.com/zhangfisher/DjangoUeditor">Django中使用Ueditor</a></p>
<p><a href="http://mushapi.sinaapp.com/using-ueditor-in-django-with-xadmin.html">http://mushapi.sinaapp.com/using-ueditor-in-django-with-xadmin.html</a></p>
<h3>1.安装</h3>
<p><code>pip install DjangoUeditor</code></p>
<h3>2.启用</h3>
<h5>在<code>INSTALL_APPS</code>里面增加DjangoUeditor app,如下:</h5>
<div class="highlight"><pre><span class="n">INSTALLED_APPS</span> <span class="o">=</span> <span class="p">(</span>
<span class="err">#</span><span class="p">........</span>
<span class="err">'</span><span class="n">DjangoUeditor</span><span class="err">'</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
<h5>在urls.py中增加:</h5>
<div class="highlight"><pre> <span class="n">url</span><span class="p">(</span><span class="n">r</span><span class="err">'</span><span class="o">^</span><span class="n">ueditor</span><span class="o">/</span><span class="err">'</span><span class="p">,</span><span class="n">include</span><span class="p">(</span><span class="err">'</span><span class="n">DjangoUeditor</span><span class="p">.</span><span class="n">urls</span><span class="err">'</span> <span class="p">)),</span>
</pre></div>
<h3>3.使用</h3>
<h5>在<code>models</code>中这样使用:</h5>
<div class="highlight"><pre><span class="n">from</span> <span class="n">DjangoUeditor</span><span class="p">.</span><span class="n">models</span> <span class="n">import</span> <span class="n">UEditorField</span>
<span class="n">class</span> <span class="n">Blog</span><span class="p">(</span><span class="n">models</span><span class="p">.</span><span class="n">Model</span><span class="p">)</span><span class="o">:</span>
<span class="n">Name</span><span class="o">=</span><span class="n">models</span><span class="p">.</span><span class="n">CharField ...</span></pre></div></div>
<footer>
<a rel="full-article" href="/ueditorzai-djangozhong-de-shi-yong.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/xadminru-men-2.html">Xadmin入门(2)</a>
</h1>
<p class="meta"><time datetime="2014-06-13T00:00:00+08:00" pubdate>Fri 13 June 2014</time></p>
</header>
<div class="entry-content"><h2>Xadmin 的插件介绍</h2>
<p>(本来想自己总结一遍的,可太喜欢Xadmin的文档了,言简意赅,排版精美,就直接搬了,望大侠们勿喷)</p>
<h3>1. Action</h3>
<h4>功能</h4>
<p>Action 插件在数据列表页面提供了数据选择功能, 选择后的数据可以经过 Action 做特殊的处理. 默认提供的 Action 为批量删除功能.</p>
<h4>截图</h4>
<p><img alt="Action" src="http://xadmin.readthedocs.org/en/docs-chinese/_images/action.png" /></p>
<h4>使用</h4>
<p>开发者可以设置 Model OptionClass 的 actions 属性, 该属性是一个列表, 包含您想启用的 Action 的类. 系统已经默认内置了删除数据的 Action, 当然您可以自己制作 Action 来实现特定的功能, 制作 Action 的实例如下.</p>
<p>首先要创建一个 Action 类, 该类需要继承 BaseActionView. BaseActionView 是 ModelAdminView 的子类:</p>
<div class="highlight"><pre><span class="n">from</span> <span class="n">xadmin ...</span></pre></div></div>
<footer>
<a rel="full-article" href="/xadminru-men-2.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/yu-men-de-fa-xian-yi-ge-shuang-bao-tai-shi-xiong.html">郁闷的发现一个双胞胎师兄</a>
</h1>
<p class="meta"><time datetime="2014-06-13T00:00:00+08:00" pubdate>Fri 13 June 2014</time></p>
</header>
<div class="entry-content"><p>今天google markdown,进了一个博客。<br />
奇迹出现了。
<a href="http://sargeraswang.github.io/">程序员小刚</a>
小刚前辈用的博客主题跟我的一模一样,也是用多说评论系统,出奇的相似。<br />
可见这个主题的确很好看,(<em>^__^</em>) 嘻嘻…… <br />
大概逛了一下,小刚前辈也是做IT的,(<em>^__^</em>) 嘻嘻…… </p></div>
<footer>
<a rel="full-article" href="/yu-men-de-fa-xian-yi-ge-shuang-bao-tai-shi-xiong.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/ba-shi-jian-dang-zuo-peng-you-du-hou-gan-1.html">把时间当作朋友读后感(1)</a>
</h1>
<p class="meta"><time datetime="2014-06-12T00:00:00+08:00" pubdate>Thu 12 June 2014</time></p>
</header>
<div class="entry-content"><p>读书最大的快乐莫过于共鸣。</p>
<hr />
<h3>我们都生活在同一个世界里,可都在自己的版本里。</h3>
<p>改变自己意味着,属于自己的版本的世界随着改变。当你的能力够大,你也能改变他人的版本,或多或少取决于你的影响力。——带来了以下问题</p>
<hr />
<p>以上的版本这个概念来自李笑来的《把时间当作朋友》,<strong>感觉措辞不够合理</strong>。我们作为程序员,用过版本号,深有体会。就像那句名言(不记得原话怎么说的):如果你觉得写的软件不够好,那就称它为1.0版本吧。每一个版本号互相之间是独立的,没有交集的。如果1.0版本出了问题,2.0版本可以是照样跑;如果3.0版本崩了,10.0版本可以是好好的</p>
<h5>世界:假设世界上有60亿人,每个人的世界都有一个版本号,我的是1.0,牛顿的是2.0,你的是3.0,罗斯福的是4.0,爱因斯坦的是5.0,乔布斯的是6.0,他的是7.0.............版本号意味着我们的世界都是独立的。很显然,我活着 ...</h5></div>
<footer>
<a rel="full-article" href="/ba-shi-jian-dang-zuo-peng-you-du-hou-gan-1.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/ba-shi-jian-dang-zuo-peng-you-du-hou-gan-2.html">把时间当作朋友读后感(2)</a>
</h1>
<p class="meta"><time datetime="2014-06-12T00:00:00+08:00" pubdate>Thu 12 June 2014</time></p>
</header>
<div class="entry-content"><h3>用正确方式做正确的事情,时间无需管理。</h3>
<h3>管理焦点不应该是时间,而是自己。</h3>
<h4>时间只是个工具,它用于把我们的生命划分成无数个块。</h4>
<p>生命就像一条高速公路,我们就像一辆不到终点不会停车的长途汽车,有时候看着路边的风景,有时候闭着眼睛养神,但无论何时我们一直在走。路标会告诉我们自己走在哪一路段,会走向哪里。而这路标就是时间</p></div>
<footer>
<a rel="full-article" href="/ba-shi-jian-dang-zuo-peng-you-du-hou-gan-2.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/bu-shu-socketio-de-demo.html">部署Socket.io 的demo</a>
</h1>
<p class="meta"><time datetime="2014-06-11T00:00:00+08:00" pubdate>Wed 11 June 2014</time></p>
</header>
<div class="entry-content"><h1>1.安装nvm</h1>
<div class="highlight"><pre><span class="err">$</span> <span class="n">wget</span> <span class="o">-</span><span class="n">qO</span><span class="o">-</span> <span class="n">https</span><span class="o">:</span><span class="c1">//raw.github.com/creationix/nvm/v0.4.0/install.sh | sh</span>
</pre></div>
<h1>2.安装node</h1>
<div class="highlight"><pre><span class="n">nvm</span> <span class="n">install</span> <span class="mf">0.1</span>
</pre></div>
<h6>若过程中如果报错,说:创建目录/usr/sbin/src 权限不够</h6>
<p>我用了个极端的方法来解决此问题,不推荐</p>
<div class="highlight"><pre><span class="n">sudo</span> <span class="n">chmod</span> <span class="mi">777</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">sbin</span><span class="o">/</span>
</pre></div>
<h1>3. 跑起</h1>
<div class="highlight"><pre><span class="n">cd</span> <span class="n">socket</span><span class="p">.</span><span class="n">io</span><span class="o">/</span><span class="n">example</span><span class="o">/</span><span class="n">chat</span><span class="o">/</span>
<span class="n">node</span> <span class="n">index</span><span class="p">.</span><span class="n">js</span>
</pre></div>
<h6>日如果报错误说,缺某某moudle,就一个个安装那些插件即可,如 ...</h6></div>
<footer>
<a rel="full-article" href="/bu-shu-socketio-de-demo.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/linux-xiao-ji-qiao-1.html">linux 小技巧(1)</a>
</h1>
<p class="meta"><time datetime="2014-05-28T00:00:00+08:00" pubdate>Wed 28 May 2014</time></p>
</header>
<div class="entry-content"><h3>1.install local deb packages:</h3>
<p><code>dpkg -i file.deb</code></p>
<h5>uninstall packages installed with dpkg:</h5>
<p><code>``dpkg -r appname</code></p>
<h5>list packages installed with dpkg:</h5>
<p><code>dpkg --get-selections | grep -v deinstall</code></p></div>
<footer>
<a rel="full-article" href="/linux-xiao-ji-qiao-1.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/django-dir-pei-zhi-fang-fa-yi.html">Django Dir 配置(方法一)</a>
</h1>
<p class="meta"><time datetime="2014-05-14T00:00:00+08:00" pubdate>Wed 14 May 2014</time></p>
</header>
<div class="entry-content"><h5>Env:</h5>
<ul>
<li>django==1.4.5</li>
<li>python==2.7</li>
<li>ubuntu==13.04</li>
</ul>
<hr />
<h3>公用部分</h3>
<p>settings.py</p>
<div class="highlight"><pre><span class="cp">##added by Tulpar,20140514</span>
<span class="n">import</span> <span class="n">os</span>
<span class="n">settings_dir</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">__file__</span><span class="p">)</span>
<span class="n">PROJECT_ROOT</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">settings_dir</span><span class="p">))</span>
</pre></div>
<h3>MEDIA</h3>
<p>settings.py</p>
<div class="highlight"><pre><span class="n">MEDIA_ROOT</span> <span class="o">=</span> <span class="n">os</span><span class="p">.</span><span class="n">path</span><span class="p">.</span><span class="n">join</span><span class="p">(</span><span class="n">PROJECT_ROOT</span><span class="p">,</span> <span class="err">'</span><span class="n">media</span><span class="o">/</span><span class="err">'</span><span class="p">)</span>
<span class="n">MEDIA_URL</span> <span class="o">=</span> <span class="err">'</span><span class="o">/</span><span class="n">media</span><span class="o">/</span><span class="err">'</span>
</pre></div>
<p>urls.py</p>
<div class="highlight"><pre><span class="err">#</span><span class="vi">#added</span> <span class="k">by</span> <span class="nx">Tulpar</span><span class="p">,</span><span class="mi">20140514 ...</span></pre></div></div>
<footer>
<a rel="full-article" href="/django-dir-pei-zhi-fang-fa-yi.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/pep8-zong-jie.html">PEP8 总结</a>
</h1>
<p class="meta"><time datetime="2014-05-14T00:00:00+08:00" pubdate>Wed 14 May 2014</time></p>
</header>
<div class="entry-content"><p>pep8除了是一个标准,也是一个软件包的名字。 <br />
提供一个pep8检测器。<br />
运行很简单:pep8 INPUT_FILES ...<br />
查看帮助:pep8 --help </p>
<p>一般来说,如果要检查代码,pylint和pep8最好都运行一下。pep8只能检测格式,pylint不仅检测格式,还检测语意。 </p>
<p>下文参考总结bobo的日记,感谢前辈分享~~~</p>
<hr />
<h2>一 代码编排</h2>
<p>1 缩进。4个空格的缩进(编辑器都可以完成此功能),不使用Tap,更不能混合使用Tap和空格。python3 已经不允许空格和Tab混用了。 <br />
2 每行最大长度79,换行可以使用反斜杠。换行点要在操作符的后边敲回车。 </p>
<div class="highlight"><pre><span class="n">with</span> <span class="n">open</span><span class="p">(</span><span class="err">'</span><span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="n">file</span><span class="o">/</span><span class="n">you</span><span class="o">/</span><span class="n">want</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">read</span><span class="err">'</span><span class="p">)</span> <span class="n">as</span> <span class="n">file_1</span><span class="p">,</span> \
<span class="n">open</span><span class="p">(</span><span class="err">'</span><span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">some</span><span class="o">/</span><span class="n">file</span><span class="o">/</span><span class="n">being</span><span class="o">/</span><span class="n">written ...</span></pre></div></div>
<footer>
<a rel="full-article" href="/pep8-zong-jie.html">Read On ↵</a>
</footer>
</article>
<article>
<header>
<h1 class="entry-title">
<a href="/yong-django-mptthou-tai-zhong-sheng-cheng-shu-zhuang-shu-ju-jie-gou.html">用Django mptt后台中生成树状数据结构</a>
</h1>
<p class="meta"><time datetime="2014-04-16T00:00:00+08:00" pubdate>Wed 16 April 2014</time></p>
</header>
<div class="entry-content"><h3>背景说明:</h3>
<p>昨天跟客户谈需求时,客户要求做一个数状数据结构,类似于:<br />
<img alt="树状数据" src="http://tulparblog.qiniudn.com/mpttsitepoint_tree.jpg" /></p>
<h5>不仅要在前台这么显示,后台也要这么显示。</h5>
<p>一番google之后 ,感谢Stack Overflow让我找到了Django mptt,感谢<a href="http://qinxuye.me/article/introduction-and-usage-of-django-mptt/">残阳似血</a>血写了如此华丽的博客,小生很喜欢添加趣点功能</p>
<hr />
<h3>解决方案</h3>
<h5>用django mptt改变数据结构</h5>
<h5>用django-mptt-admin改变数状结构在django后台的显示方式</h5>
<h3>具体操作</h3>
<h4>1. 安装django mptt</h4>
<p>下载源码 <code>https://github.com/django-mptt/django-mptt</code>
<em>或</em>
<code>pip install django-mptt</code></p>
<h4>2. 配置django mptt</h4>
<p>在settings文件下的INSTALLED_APPS中添加'mptt'<br />
<em>就这么简单,安装配置结束了</em></p>
<h4>3. 使用django mptt</h4>
<h5>写model,继承MPTTModel</h5>
<div class="highlight"><pre><span class="n">from</span> <span class="n">mptt</span><span class="p">.</span><span class="n">models</span> <span class="n">import</span> <span class="n">MPTTModel</span>
<span class="n">class ...</span></pre></div></div>
<footer>
<a rel="full-article" href="/yong-django-mptthou-tai-zhong-sheng-cheng-shu-zhuang-shu-ju-jie-gou.html">Read On ↵</a>
</footer>
</article>
<div class="pagination">
<a class="prev" href="/index5.html">← Older</a>
<a class="next" href="/index3.html">Newer →</a>
<br />
</div></div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/xie-bo-ke-jiao-ben.html">写博客脚本</a>
</li>
<li class="post">
<a href="/gong-zuo-shi-de-sui-bi.html">工作时的随笔</a>
</li>
<li class="post">
<a href="/ce-shi-wen-zhang.html">测试文章</a>
</li>
<li class="post">
<a href="/djangokai-qi-the-sites-framework.html">Django开启 the sites framework</a>
</li>
<li class="post">
<a href="/django-17shi-yong.html">Django 1.7试用</a>
</li>
</ul>
</section>
<section>
<h1>Categories</h1>
<ul id="recent_posts">
<li><a href="/category/it.html">It</a></li>
<li><a href="/category/life.html">Life</a></li>
</ul>
</section>
<section>
<h1>Tags</h1>
<a href="/tag/mysql.html">Mysql</a>, <a href="/tag/tmux.html">Tmux</a>, <a href="/tag/fan-qiang.html">翻墙</a>, <a href="/tag/linux.html">Linux</a>, <a href="/tag/edx.html">Edx</a>, <a href="/tag/virtualbox.html">VirtualBox</a>, <a href="/tag/wo-ai-wo-jia.html">我爱我家</a>, <a href="/tag/userena.html">userena</a>, <a href="/tag/xadmin.html">Xadmin</a>, <a href="/tag/shell.html">Shell</a>, <a href="/tag/python.html">Python</a>, <a href="/tag/djangopython.html">Django,python</a>, <a href="/tag/ssh.html">ssh</a>, <a href="/tag/ubuntu.html">Ubuntu</a>, <a href="/tag/git.html">Git</a>, <a href="/tag/ce-shi.html">测试</a>, <a href="/tag/ueditor.html">Ueditor</a>, <a href="/tag/github.html">Github</a>, <a href="/tag/socketio.html">Socket.io</a>, <a href="/tag/django.html">Django</a>, <a href="/tag/du-shu.html">读书</a>, <a href="/tag/bo-ke.html">博客</a>, <a href="/tag/ngrok.html">ngrok</a> </section>
<section>
<h1>Social</h1>
<ul>
<li><a href="http://izda.com" target="_blank">ئىزدە</a></li>
<li><a href="http://www.google.com" target="_blank">Google</a></li>
<li><a href="http://www.zhihu.com/" target="_blank">知乎</a></li>
<li><a href="http://www.douban.com/" target="_blank">豆瓣</a></li>
</ul>
</section>
<section>
<h1>Blogroll</h1>
<ul>
<li><a href="https://github.com/tulpar008" target="_blank">My Github</a></li>
<li><a href="#" target="_blank">tulpar008@gmail.com</a></li>
</ul>
</section>
</aside> </div>
</div>
<footer role="contentinfo"><p>
Copyright © 2013-2015 - tulpar -
<span class="credit">Powered by <a href="http://getpelican.com">Pelican</a></span>
</p></footer>
</body>
</html>