首页 新闻 搜索 专区 学院

django:TypeError at /bbs_sub/ 'author' is an invalid keyword argument for this function

-1
[已关闭问题] 关闭于 2017-08-20 22:35

model:

class BBS(models.Model):
title = models.CharField(max_length=64)
summary = models.CharField(max_length=256,blank=True,null=True)
content = models.TextField()
auther = models.ForeignKey('BBS_user')
view_count = models.IntegerField()
ranking = models.IntegerField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)

......

class BBS_user(models.Model):
user = models.OneToOneField(User)
signature = models.CharField(max_length=128,default='This guy is too lazy to levave anything here.')
photo = models.ImageField(upload_to="upload_imgs/",default="upload_imgs/user-1.jpg")
def __unicode__(self):
return self.user.username

------------

views:

def bbs_sub(request):
print ',==>',request.POST.get('content')
content = request.POST.get('content')
author = models.BBS_user.objects.get(user__username=request.user)
models.BBS.objects.create(
title = 'TEST TITLE',
summary = 'HAHA',
content = content,
author =author,
view_count= 1,
ranking = 1,
)
return HttpResponse('yes.')
def bbs_pub(request):
return render_to_response('bbs_pub.html')

--------------

url(r'^bbs_pub/$',views.bbs_pub),
url(r'^bbs_sub/$',views.bbs_sub),

提交报错如:标题,请大神帮忙,我是初学者。谢谢~!

宝宝佩恩天道的主页 宝宝佩恩天道 | 菜鸟二级 | 园豆:202
提问于:2016-12-07 22:39
< >
分享
所有回答(1)
-1

有点难啊兄弟

muamuamua | 园豆:222 (菜鸟二级) | 2016-12-08 09:30

帮我一起解决吧~!

支持(0) 反对(2) 宝宝佩恩天道 | 园豆:202 (菜鸟二级) | 2016-12-08 23:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册