This commit is contained in:
Bob 2020-09-25 22:15:45 +08:00
parent 1d4417d438
commit 8a54c0ea48
2 changed files with 16 additions and 5 deletions

View File

@ -16,8 +16,8 @@
{% block content %} {% block content %}
<div class="page-sidebar "> <div class="page-sidebar ">
{% include 'dashboard/base/left.html' %} {% include 'dashboard/base/left.html' %}
</div> </div>
<div class="container"> <div class="container">
{% if messages %} {% if messages %}
@ -38,7 +38,7 @@
</div> </div>
<form action="{% url 'news-management-create' %}" method="post">{% csrf_token %} <form action="{% url 'news-management-create' %}" method="post" enctype="multipart/form-data">{% csrf_token %}
<div class="panel-body col-md-12"> <div class="panel-body col-md-12">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="title">新闻标题</label> <label for="title">新闻标题</label>
@ -65,12 +65,21 @@
<input type="date" class="form-control" id="source" <input type="date" class="form-control" id="source"
name="date"> name="date">
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="source">来源</label> <label for="source">来源</label>
<input type="text" class="form-control" id="source" <input type="text" class="form-control" id="source"
name="source"> name="source">
</div> </div>
<div class="form-group col-md-12" >
<label class="form-label" for="image">图片
<div class="controls">
<input type="file" name="image">
</div>
</label>
</div>
</div> </div>
<div class="row"> <div class="row">
<label for="country">正文</label> <label for="country">正文</label>

View File

@ -1211,6 +1211,8 @@ def news_management_create(request):
date = request.POST.get('date') date = request.POST.get('date')
content = request.POST.get('content') content = request.POST.get('content')
source = request.POST.get('source') source = request.POST.get('source')
image = request.FILES.get('image')
print(str(image) + "5555555555555555555555555")
t = None t = None
if type == '政策依据': if type == '政策依据':
t = '0' t = '0'
@ -1228,7 +1230,7 @@ def news_management_create(request):
t = '6' t = '6'
print(str(title), str(content)) print(str(title), str(content))
news = News(type=t, title=title, author=author, date=date, content=content,source=source) news = News(type=t, title=title, author=author, date=date, content=content,source=source,image=image)
news.save() news.save()
messages.success(request, '添加成功!!!') messages.success(request, '添加成功!!!')
return HttpResponseRedirect('/management/news/management/create/') return HttpResponseRedirect('/management/news/management/create/')