1 from django.views.generic.simple import direct_to_template
2 from django.http import HttpResponse, HttpResponseRedirect
4 from wiki.models import storage, Document, DocumentNotFound
5 from wiki.forms import DocumentForm
8 def document_list(request, template_name='wiki/document_list.html'):
9 return direct_to_template(request, template_name, extra_context={
10 'document_list': storage.all(),
14 def document_detail(request, name, template_name='wiki/document_details.html'):
16 document = storage.get(name)
17 except DocumentNotFound:
18 document = Document(storage, name=name, text='')
20 if request.method == 'POST':
21 form = DocumentForm(request.POST, instance=document)
24 return HttpResponse('OK')
28 form = DocumentForm(instance=document)
30 return direct_to_template(request, template_name, extra_context={