announcement model.py 里面的 description 改名为 content,并修改其对应的serializers和views
This commit is contained in:
19
announcement/migrations/0002_auto_20150806_1104.py
Normal file
19
announcement/migrations/0002_auto_20150806_1104.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('announcement', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='announcement',
|
||||
old_name='description',
|
||||
new_name='content',
|
||||
),
|
||||
]
|
||||
@@ -7,8 +7,8 @@ from account.models import User
|
||||
class Announcement(models.Model):
|
||||
# 标题
|
||||
title = models.CharField(max_length=50)
|
||||
# 公告的描述 HTML 格式
|
||||
description = models.TextField()
|
||||
# 公告的内容 HTML 格式
|
||||
content = models.TextField()
|
||||
# 创建时间
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
# 这个公告是谁创建的
|
||||
|
||||
@@ -4,5 +4,5 @@ from rest_framework import serializers
|
||||
|
||||
class AnnouncementSerializer(serializers.Serializer):
|
||||
title = serializers.CharField(max_length=50)
|
||||
description = serializers.CharField(max_length=10000)
|
||||
content = serializers.CharField(max_length=10000)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class AnnouncementAPIView(APIView):
|
||||
if serializer.is_valid():
|
||||
data = serializer.data
|
||||
Announcement.objects.create(title=data["title"],
|
||||
description=data["description"],
|
||||
content=data["content"],
|
||||
created_by=request.user)
|
||||
return success_response(u"公告发布成功!")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user