diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index 6505c5c..f95925a 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ diff --git a/article/__pycache__/views.cpython-36.pyc b/article/__pycache__/views.cpython-36.pyc index c630eda..b4d040d 100644 Binary files a/article/__pycache__/views.cpython-36.pyc and b/article/__pycache__/views.cpython-36.pyc differ diff --git a/article/migrations/0014_auto_20180228_1552.py b/article/migrations/0014_auto_20180228_1552.py new file mode 100644 index 0000000..96016b2 --- /dev/null +++ b/article/migrations/0014_auto_20180228_1552.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-02-28 07:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('article', '0013_auto_20180226_1938'), + ] + + operations = [ + migrations.AlterField( + model_name='comment', + name='ip', + field=models.GenericIPAddressField(blank=True, default='0.0.0.0', null=True), + ), + ] diff --git a/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc b/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc new file mode 100644 index 0000000..31b2f36 Binary files /dev/null and b/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc differ diff --git a/article/models.py b/article/models.py index 347fb3e..c70247b 100644 --- a/article/models.py +++ b/article/models.py @@ -51,15 +51,22 @@ class ArticleForm(ModelForm): class Meta: model = Article fields = ['title','author','author_id','section','tag','cover','detail'] + error_messages = { + 'section':{'required': '请选择主题分区'}, + 'author':{'required': '请输入作者名称'}, + 'cover':{'required': '请上传封面图'}, + 'detail':{'required': '请输入正文内容'}, + 'title':{'required': '请输入文章标题'}, + + } widgets = { - 'detail':TinyMCE(attrs={'cols':'100%','rows':30}), - 'cover':ClearableFileInput(attrs={'style':'width:50%','class':'form-control','placeholder':"封面"}), - 'tag':TextInput(attrs={'class':'form-control','placeholder':"添加标签,回车确认",'data-role':'tagsinput'}), - 'author':TextInput(attrs={'class':'form-control','placeholder':"署名"}), - 'title':TextInput(attrs={'style':'width:50%','class':'form-control','placeholder':"标题"}), - 'section':widgets.Select(choices=Section.objects.values_list('id','name'),attrs={'class':'form-control','placeholder':"标题"}), - - } + 'detail':TinyMCE(attrs={'cols':'100%','rows':30}), + 'cover':ClearableFileInput(attrs={'style':'width:50%','class':'form-control','placeholder':"封面"}), + 'tag':TextInput(attrs={'class':'form-control','placeholder':"添加标签,回车确认",'data-role':'tagsinput'}), + 'author':TextInput(attrs={'class':'form-control','placeholder':"署名"}), + 'title':TextInput(attrs={'style':'width:50%','class':'form-control','placeholder':"标题"}), + 'section':widgets.Select(choices=Section.objects.values_list('id','name'),attrs={'class':'form-control','placeholder':"标题"}), + } class Comment(models.Model): diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index c962ae4..64b5055 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -2,6 +2,7 @@ {% block header %}