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:
parent
0121e4cc94
commit
c3b7f4b0a9
@ -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
|
||||
# the last two arguments to FormWrapper for now.
|
||||
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
|
||||
first example above.)
|
||||
@ -161,7 +161,7 @@ creation view that takes validation into account::
|
||||
# Check for validation errors
|
||||
errors = manipulator.get_validation_errors(new_data)
|
||||
if errors:
|
||||
return render_to_response('places/errors', {'errors': errors})
|
||||
return render_to_response('places/errors.html', {'errors': errors})
|
||||
else:
|
||||
manipulator.do_html2python(request.POST)
|
||||
new_place = manipulator.save(request.POST)
|
||||
@ -233,7 +233,7 @@ Below is the finished view::
|
||||
|
||||
# Create the FormWrapper, template, context, response.
|
||||
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::
|
||||
|
||||
@ -322,7 +322,7 @@ about editing an existing one? It's shockingly similar to creating a new one::
|
||||
new_data = place.__dict__
|
||||
|
||||
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:
|
||||
|
||||
@ -401,7 +401,7 @@ Here's a simple function that might drive the above form::
|
||||
else:
|
||||
errors = new_data = {}
|
||||
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
|
||||
==========
|
||||
|
@ -198,7 +198,7 @@ article_detail from above::
|
||||
def article_detail(request, year, month, article_id):
|
||||
# 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)
|
||||
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.
|
||||
|
||||
|
@ -141,7 +141,7 @@ Here's a typical usage example::
|
||||
else:
|
||||
return HttpResponse("Please enable cookies and try again.")
|
||||
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
|
||||
===========================
|
||||
|
@ -101,7 +101,7 @@ page for the poll. Let's write that view::
|
||||
|
||||
def results(request, 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`_.
|
||||
The only difference is the template name. We'll fix this redundancy later.
|
||||
|
Loading…
x
Reference in New Issue
Block a user