-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
初学者,有一个疑问,希望能细心解答 #22
Comments
1.如果不定义这个函数,我们在模版中访问一个单元条记录的时候,哪链接是这样的一条记录: 2.这个问题,你可以看下这里: http://zhangfortune.iteye.com/blog/2124979 3.这个其实就是一个正则分组,指定名称之后,你在编写相应的views的时候,就可以关联上指定的这个组名了。 希望能你有所帮助。 如果初学Django,建议可以先看看Django Book,中英文都有,有个大致认识之后再试着做些小项目。 |
哦,非常感谢你的细致回答,明白了a |
get_absolute_url 这个函数名字应该是约定的吧 可以写短的名字 pk是取已经有的字段的主键 可以用id代替(如果id是默认主键的话),不过有多个主键就不知道怎么样弄了 |
@yuzeshan 我使用的是Nginx+FastCGI |
@wwq0327 有比较细致的部署教程吗?给我发份过来呗!网上鱼龙混杂的,谢啦! |
请用 nginx + gunicorn |
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+)正则表达式又是什么意思呢?
问题比较多,请原谅我这个菜鸟。
The text was updated successfully, but these errors were encountered: