1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

magic-removal: fixed #1666 render_to_response '.html' updates for documentation. Thanks SmileyChris

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2721 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans 2006-04-21 19:01:17 +00:00
parent 0121e4cc94
commit c3b7f4b0a9
4 changed files with 8 additions and 8 deletions

View File

@ -110,7 +110,7 @@ view with a form that submits to this flawed creation view::
# Create a FormWrapper object that the template can use. Ignore # Create a FormWrapper object that the template can use. Ignore
# the last two arguments to FormWrapper for now. # the last two arguments to FormWrapper for now.
form = forms.FormWrapper(places.AddManipulator(), {}, {}) form = forms.FormWrapper(places.AddManipulator(), {}, {})
return render_to_response('places/naive_create_form', {'form': form}) return render_to_response('places/naive_create_form.html', {'form': form})
(This view, as well as all the following ones, has the same imports as in the (This view, as well as all the following ones, has the same imports as in the
first example above.) first example above.)
@ -161,7 +161,7 @@ creation view that takes validation into account::
# Check for validation errors # Check for validation errors
errors = manipulator.get_validation_errors(new_data) errors = manipulator.get_validation_errors(new_data)
if errors: if errors:
return render_to_response('places/errors', {'errors': errors}) return render_to_response('places/errors.html', {'errors': errors})
else: else:
manipulator.do_html2python(request.POST) manipulator.do_html2python(request.POST)
new_place = manipulator.save(request.POST) new_place = manipulator.save(request.POST)
@ -233,7 +233,7 @@ Below is the finished view::
# Create the FormWrapper, template, context, response. # Create the FormWrapper, template, context, response.
form = forms.FormWrapper(manipulator, new_data, errors) form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('places/create_form', {'form': form}) return render_to_response('places/create_form.html', {'form': form})
and here's the ``create_form`` template:: and here's the ``create_form`` template::
@ -322,7 +322,7 @@ about editing an existing one? It's shockingly similar to creating a new one::
new_data = place.__dict__ new_data = place.__dict__
form = forms.FormWrapper(manipulator, new_data, errors) form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('places/edit_form', {'form': form, 'place': place}) return render_to_response('places/edit_form.html', {'form': form, 'place': place})
The only real differences are: The only real differences are:
@ -401,7 +401,7 @@ Here's a simple function that might drive the above form::
else: else:
errors = new_data = {} errors = new_data = {}
form = forms.FormWrapper(manipulator, new_data, errors) form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('contact_form', {'form': form}) return render_to_response('contact_form.html', {'form': form})
Validators Validators
========== ==========

View File

@ -198,7 +198,7 @@ article_detail from above::
def article_detail(request, year, month, article_id): def article_detail(request, year, month, article_id):
# Use the Django API to find an object matching the URL criteria. # Use the Django API to find an object matching the URL criteria.
a = get_object_or_404(articles, pub_date__year=year, pub_date__month=month, pk=article_id) a = get_object_or_404(articles, pub_date__year=year, pub_date__month=month, pk=article_id)
return render_to_response('news/article_detail', {'article': a}) return render_to_response('news/article_detail.html', {'article': a})
This example uses Django's template system, which has several key features. This example uses Django's template system, which has several key features.

View File

@ -141,7 +141,7 @@ Here's a typical usage example::
else: else:
return HttpResponse("Please enable cookies and try again.") return HttpResponse("Please enable cookies and try again.")
request.session.set_test_cookie() request.session.set_test_cookie()
return render_to_response('foo/login_form') return render_to_response('foo/login_form.html')
Using sessions out of views Using sessions out of views
=========================== ===========================

View File

@ -101,7 +101,7 @@ page for the poll. Let's write that view::
def results(request, poll_id): def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id) p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/results', {'poll': p}) return render_to_response('polls/results.html', {'poll': p})
This is almost exactly the same as the ``detail()`` view from `Tutorial 3`_. This is almost exactly the same as the ``detail()`` view from `Tutorial 3`_.
The only difference is the template name. We'll fix this redundancy later. The only difference is the template name. We'll fix this redundancy later.