models.py
class Book(models.Model):
book_name = models.CharField(max_length = 32, unique = True)
author_name = models.CharField(max_length = 32, unique = True)
publisher_name = models.CharField(max_length = 32, unique = True)
forms.py
パスから本をインポートする
class BookForm(forms.ModelForm):
class = Book
view.py
def save_book(request):
form = BookForm
if request.POST:
form = BookForm(request.POST)
if form.is_valid():
form.save()
return render_to_response('book.html.html',{'form': form} , context_instance=RequestContext(request))
book.html
<body>
<form action="." method="post" name="book" id="book">{% csrf_token %}
<table>
<tr><td>{{form.book_name.label}}</td><td>{{form.book_name}}</td></tr>
<tr><td>{{form.author_name.label}}</td><td>{{form.author_name}}</td></tr>
<tr><td>{{form.publisher_name.label}}</td><td>{{form.publisher_name}}</td></tr>
<tr><td></td><td><input type="button" name="btnSave" id="bntSave" value="Save" class = "default2"/></td>
</table>
</body>
url.pyはあなたのURLを呼び出します