| | 558 | The ``render_to_string()`` and ``render_to_response()`` shortcuts |
| | 559 | ================================================================= |
| | 560 | |
| | 561 | To cut down on the repetitive nature of loading and rendering |
| | 562 | templates, Django provides two shortcut functions which largely |
| | 563 | automate the process: ``render_to_string()`` in |
| | 564 | ``django.template.loader`` and ``render_to_response()`` in |
| | 565 | ``django.shortcuts``. |
| | 566 | |
| | 567 | ``django.template.loader.render_to_string()`` |
| | 568 | --------------------------------------------- |
| | 569 | |
| | 570 | Renders a template and returns the resulting string. |
| | 571 | |
| | 572 | **Required arguments:** |
| | 573 | |
| | 574 | template_name |
| | 575 | The name of the template to render. Can also be passed as the |
| | 576 | first positional argument. |
| | 577 | |
| | 578 | **Optional arguments:** |
| | 579 | |
| | 580 | dictionary |
| | 581 | A dictionary to be used as variables and values for the |
| | 582 | template's context. Can also be passed as the second |
| | 583 | positional argument. |
| | 584 | |
| | 585 | context_instance |
| | 586 | An instance of ``Context`` or a subclass (e.g., an instance of |
| | 587 | ``RequestContext``) to use as the template's context. Can also |
| | 588 | be passed as the third positional argument. |
| | 589 | |
| | 590 | ``django.shortcuts.render_to_response()`` |
| | 591 | ----------------------------------------- |
| | 592 | |
| | 593 | Like ``render_to_string``, but returns an ``HttpResponse`` object with |
| | 594 | the rendered template as its contents. |
| | 595 | |
| | 596 | **Required arguments** |
| | 597 | |
| | 598 | template_name |
| | 599 | The name of the template to render. Can also be passed as the |
| | 600 | first positional argument. |
| | 601 | |
| | 602 | **Optional arguments** |
| | 603 | |
| | 604 | dictionary |
| | 605 | A dictionary to be used as variables and values for the |
| | 606 | template's context. Can also be passed as the second |
| | 607 | positional argument. |
| | 608 | |
| | 609 | context_instance |
| | 610 | An instance of ``Context`` or a subclass (e.g., an instance of |
| | 611 | ``RequestContext``) to use as the template's context. Can also |
| | 612 | be passed as the third positional argument. |
| | 613 | |
| | 614 | mimetype |
| | 615 | The HTTP Content-Type to use for the ``HttpResponse``. Must be |
| | 616 | passed as a keyword argument. |
| | 617 | |