我在将一些字符串附加到数据库列表中时遇到问题请帮助我
这是我的models.py
class friendList(models.TextField):
myFriend = []
class friend(models.Model):
username = models.CharField(max_length="30")
friends = friendList().myFriend
这是 view.py
def addfriend(request):
try:
user = request.session['user']
if request.method == 'POST':
friend.objects.filter(username = user.username)[0].friends.append(request.POST['user_name'])
return HttpResponse("ok he/she is your friend now!!")
except:
return render(request, 'login.html', {'error':"you are not logged in"})