状況
djangoでWEBアプリを作成しています。
htmlに変数{{ form.as_table }}を記述しているのですが、
全く表示されず空白になってしまいます。
質問
可能性として考えられる原因をご教示ください。
お手数をお掛けしますがよろしくお願い致します。
html
1{% extends 'base.html' %} 2{% block content %} 3<div class="col-lg-6 offset-lg-3"> 4{% load static %} 5<!DOCTYPE html> 6<html lang="ja"> 7<head> 8 <meta charset="UTF-8"> 9 <title>{{ title }}</title> 10 <link rel="stylesheet" type="text/css" href="{% static 'app/css/sb-admin-2.min.css' %}"> 11</head> 12<body> 13 <h1>{{ title }}</h1> 14 <table> 15 <form action="{% url 'app:create' %}" method="post"> 16 {% csrf_token %} 17 {{ form.as_table }} 18 <tr><td><input type="submit" value="作成"></td></tr> 19 </form> 20 </table> 21</body> 22</html> 23{% endblock %}
view
1class AccountCreateView(LoginRequiredMixin, generic.ListView): 2 paginate_by = 20 3 template_name = 'app/create.html' 4 model = AccountModel 5 def create(request): 6 if (request.method == 'POST'): 7 obj = AccountModel() 8 info = AccountAddForm(request.POST,instance=obj) 9 info.save() 10 return redirect(to='/accountapp/index') 11 data = { 12 'form' : AccountAddForm, 13 } 14 return render(request, 'app/create.html',data)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。