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),
提交报错如:标题,请大神帮忙,我是初学者。谢谢~!
有点难啊兄弟
帮我一起解决吧~!