wwq0327 / django-web-app-book Goto Github PK
View Code? Open in Web Editor NEWDjango Web 开发实战
Home Page: http://django-web-app-book.wanqingwong.com/
License: MIT License
Django Web 开发实战
Home Page: http://django-web-app-book.wanqingwong.com/
License: MIT License
url(r"^", "blog.views.index", name="index"),
r"^", 少了$ 不然所有的url 都匹配到 index里去了
声明中有一句"而不是人零开始来做这么一个功能",是”从“。
<a class="navbar-brand" href="#">DJBlog</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">首页</a></li>
<li><a href="#about">关于</a></li>
</ul>
默认是上面这么写的
首页是不是应该 换成 /blog 不然直接导航到 域名的根页面去了
navbar-brand 以后如果也设成到blog index的链接 那首页的li 是不是可以去除了
如果你使用了一些第三方应用,就应用安装好之后,你也需要将应用名添加到这个无组中去。
这个无组中去??????????
元组把 目测楼主是五笔输入法
所有的页面就显示2篇文章,但没有分页标签的
cat djblog/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
第一个url应该是
url(r'^', include('blog.urls')),没有$
main.css 的内容在这里没写 直接跳过了
这里没有提示 要添加 category到admin.py
后台会访问不了
这个教程是用md写的吧?
那边上的目录及导航栏很好看,也看到过类似的网站,请问是用什么框架写的吗?
最近有个东西要写,想要用这种方式展示
这里是不是应该写成
我们这里通过django 自定义template filter的方式来实现解析文章内容。
template tag 和 template filter 应该是不同的东西
filter 带管道的功能 tag 只是输出一些东西
它们都定义在templatetags 目录里面
对于blog/post.html的修改方式类似,代码如下:
这里不该这么写吧
因为blog/post.html 在上文还没用创建
应该新建如下
blog.views.index和blog.views.post修改代码都是一样的
应该是不一样的
index 是 posts
post 是post
如果 class Category 定义在Post的下面
south的时候 会出现
NameError: name 'Category' is not defined
建议加引号
po_type = models.ForeignKey('Category', verbose_name=u'文章分类', blank=True, null=True)
原来是路径打错了。。。
本书的目录暂定这样的,如果你有更好的建议,请在这里留言。
blog 项目生成错误
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
get_absolute_url 没写
后面的template 里出现了
1、编写数据模型时,@models.permalink def get_absolute_url(self): return ('post', (), {'pk': self.pk})定义这个函数是什么意思呢?
2、views中post = get_object_or_404(Post, pk=pk)这个怎么能获取数据库中指定的内容对象?pk是什么呢?
3、编写urls时,?P\d+)正则表达式又是什么意思呢?
问题比较多,请原谅我这个菜鸟。
分类 name 写成
<script>alert(1111)</script>
也行啊
posts = get_list_or_404(Post)
这样好像不大好吧
如果没有文章 blog index主页也不该显示404啊
这个板块下面怎么写了 评论实现?
评论是不是应该考虑新建一个板块写
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.