update.html 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {% extends "base.html" %}
  2. {% load static %}
  3. {% block title %}
  4. 更新文章
  5. {% endblock title %}
  6. {% block content %}
  7. <div class="container">
  8. <div class="row">
  9. <div class="col-12">
  10. <br>
  11. <form method="post" action=".">
  12. {% csrf_token %}
  13. <div class="form-group">
  14. <label for="title">
  15. 文章标题
  16. </label>
  17. <input type="text" class="form-control" id="title" name="title" value="{{ article.title }}">
  18. </div>
  19. {% if article.avatar %}
  20. <div class="col-3">
  21. <img src="{{ article.avatar.url }}"
  22. alt="avatar"
  23. style="max-width: 100%; border-radius: 20px;"
  24. >
  25. </div>
  26. {% else %}
  27. <div class="form-group">
  28. <label for="avatar">标题图</label>
  29. <input type="file" class="form-control-file" name="avatar" id="avatar">
  30. </div>
  31. {% endif %}
  32. <div class="form-group">
  33. <label for="column">分类</label>
  34. <select class="form-control"
  35. id="column"
  36. name="column"
  37. >
  38. <option value="none">请选择分类..</option>
  39. {% for column in columns %}
  40. <option value="{{ column.id }}"
  41. {% if column.id == article.column.id %}
  42. selected
  43. {% endif %}
  44. >
  45. {{ column }}
  46. </option>
  47. {% endfor %}
  48. </select>
  49. </div>
  50. <div class="form-group">
  51. <label for="body">
  52. 文章正文
  53. </label>
  54. <textarea type="text" class="form-control" id="body" name="body" rows="12">
  55. {{ article.body }}
  56. </textarea>
  57. </div>
  58. <button type="submit" class="btn btn-primary">
  59. 提交
  60. </button>
  61. </form>
  62. </div>
  63. </div>
  64. </div>
  65. {% endblock content %}