obj_import.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. {% extends '_base.html' %}
  2. {% load helpers %}
  3. {% load form_helpers %}
  4. {% block content %}
  5. <h1>{% block title %}{{ obj_type|bettertitle }} Import{% endblock %}</h1>
  6. {% block tabs %}{% endblock %}
  7. <div class="row">
  8. <div class="col-md-7">
  9. {% if form.non_field_errors %}
  10. <div class="panel panel-danger">
  11. <div class="panel-heading"><strong>Errors</strong></div>
  12. <div class="panel-body">
  13. {{ form.non_field_errors }}
  14. </div>
  15. </div>
  16. {% endif %}
  17. <form action="" method="post" class="form">
  18. {% csrf_token %}
  19. {% render_form form %}
  20. <div class="form-group">
  21. <div class="col-md-12 text-right">
  22. <button type="submit" class="btn btn-primary">Submit</button>
  23. {% if return_url %}
  24. <a href="{% url return_url %}" class="btn btn-default">Cancel</a>
  25. {% endif %}
  26. </div>
  27. </div>
  28. </form>
  29. </div>
  30. <div class="col-md-5">
  31. {% if fields %}
  32. <h4 class="text-center">CSV Format</h4>
  33. <table class="table">
  34. <tr>
  35. <th>Field</th>
  36. <th>Required</th>
  37. <th>Description</th>
  38. </tr>
  39. {% for name, field in fields.items %}
  40. <tr>
  41. <td><code>{{ name }}</code></td>
  42. <td>{% if field.required %}<i class="glyphicon glyphicon-ok" title="Required"></i>{% endif %}</td>
  43. <td>
  44. {{ field.help_text|default:field.label }}
  45. {% if field.choices %}
  46. <br /><small class="text-muted">Choices: {{ field|example_choices }}</small>
  47. {% elif field|widget_type == 'dateinput' %}
  48. <br /><small class="text-muted">Format: YYYY-MM-DD</small>
  49. {% elif field|widget_type == 'checkboxinput' %}
  50. <br /><small class="text-muted">Specify "true" or "false"</small>
  51. {% endif %}
  52. </td>
  53. </tr>
  54. {% endfor %}
  55. </table>
  56. {% endif %}
  57. </div>
  58. </div>
  59. {% endblock %}