Ticket #1666: render_to_response_in_docs.patch
File render_to_response_in_docs.patch, 3.7 KB (added by , 19 years ago) |
---|
-
docs/forms.txt
110 110 # Create a FormWrapper object that the template can use. Ignore 111 111 # the last two arguments to FormWrapper for now. 112 112 form = forms.FormWrapper(places.AddManipulator(), {}, {}) 113 return render_to_response('places/naive_create_form ', {'form': form})113 return render_to_response('places/naive_create_form.html', {'form': form}) 114 114 115 115 (This view, as well as all the following ones, has the same imports as in the 116 116 first example above.) … … 161 161 # Check for validation errors 162 162 errors = manipulator.get_validation_errors(new_data) 163 163 if errors: 164 return render_to_response('places/errors ', {'errors': errors})164 return render_to_response('places/errors.html', {'errors': errors}) 165 165 else: 166 166 manipulator.do_html2python(request.POST) 167 167 new_place = manipulator.save(request.POST) … … 233 233 234 234 # Create the FormWrapper, template, context, response. 235 235 form = forms.FormWrapper(manipulator, new_data, errors) 236 return render_to_response('places/create_form ', {'form': form})236 return render_to_response('places/create_form.html', {'form': form}) 237 237 238 238 and here's the ``create_form`` template:: 239 239 … … 322 322 new_data = place.__dict__ 323 323 324 324 form = forms.FormWrapper(manipulator, new_data, errors) 325 return render_to_response('places/edit_form ', {'form': form, 'place': place})325 return render_to_response('places/edit_form.html', {'form': form, 'place': place}) 326 326 327 327 The only real differences are: 328 328 … … 401 401 else: 402 402 errors = new_data = {} 403 403 form = forms.FormWrapper(manipulator, new_data, errors) 404 return render_to_response('contact_form ', {'form': form})404 return render_to_response('contact_form.html', {'form': form}) 405 405 406 406 Validators 407 407 ========== -
docs/overview.txt
198 198 def article_detail(request, year, month, article_id): 199 199 # Use the Django API to find an object matching the URL criteria. 200 200 a = get_object_or_404(articles, pub_date__year=year, pub_date__month=month, pk=article_id) 201 return render_to_response('news/article_detail ', {'article': a})201 return render_to_response('news/article_detail.html', {'article': a}) 202 202 203 203 This example uses Django's template system, which has several key features. 204 204 -
docs/sessions.txt
141 141 else: 142 142 return HttpResponse("Please enable cookies and try again.") 143 143 request.session.set_test_cookie() 144 return render_to_response('foo/login_form ')144 return render_to_response('foo/login_form.html') 145 145 146 146 Using sessions out of views 147 147 =========================== -
docs/tutorial04.txt
101 101 102 102 def results(request, poll_id): 103 103 p = get_object_or_404(Poll, pk=poll_id) 104 return render_to_response('polls/results ', {'poll': p})104 return render_to_response('polls/results.html', {'poll': p}) 105 105 106 106 This is almost exactly the same as the ``detail()`` view from `Tutorial 3`_. 107 107 The only difference is the template name. We'll fix this redundancy later.