本文整理汇总了Python中models.Blog.user方法的典型用法代码示例。如果您正苦于以下问题:Python Blog.user方法的具体用法?Python Blog.user怎么用?Python Blog.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Blog
的用法示例。
在下文中一共展示了Blog.user方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: blog_add
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import user [as 别名]
def blog_add():
user_now = current_user()
blog = Blog(request.form)
blog.user = user_now
blog.save()
log('发布成功')
return redirect(url_for('timeline_view', username=user_now.username))
示例2: post
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import user [as 别名]
def post(request):
if (request.method=='POST'):
data=JSONParser().parse(request)
blog = Blog()
if(data['title'] and data['blogpost']):
blog.title = data['title']
blog.user = request.user
blog.blogpost = data['blogpost']
blog.save()
return HttpResponseRedirect('/blog/userhome/',status=status.HTTP_200_OK)
示例3: save
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import user [as 别名]
def save(self, request):
if not self.is_valid():
return None
blogid = self.cleaned_data["blogid"]
title = self.cleaned_data["title"]
markdown = self.cleaned_data["markdown"]
if blogid:
blog = Blog.objects.get(id=int(blogid))
else:
blog = Blog()
blog.title = title
blog.markdown = markdown
blog.user = request.user
blog = blog.save()
return blog
示例4: create_blog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import user [as 别名]
def create_blog (request):
if request.POST:
print request.POST
blog = Blog()
blog.user = request.user
blog.title = request.POST.get('title')
blog.description = request.POST.get('description')
##<<<<<<< HEAD
## blog.tags = request.POST.get('blog_tags')
##=======
## blog.tags = request.POST.get('tags')
##>>>>>>> 3eb972486d29895357819facd4a4c89bdc1b241f
blog.save()
return redirect_to (request, '/')
else:
from forms import BlogForm
form = BlogForm
return render(request, 'blog/blog.html', {'form':form})
示例5: addblog
# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import user [as 别名]
def addblog(req):
blog = Blog()
blog.user = req.user
form = BlogForm(instance=blog)
return render_to_response("post.html", {"settings": settings, "form": form}, context_instance=RequestContext(req))