Ticket #17148: 17148.diff
File 17148.diff, 3.6 KB (added by , 13 years ago) |
---|
-
docs/ref/contrib/formtools/form-wizard.txt
304 304 Example to add extra variables for a specific step:: 305 305 306 306 def get_context_data(self, form, **kwargs): 307 context = super(MyWizard, self).get_context_data(form , **kwargs)307 context = super(MyWizard, self).get_context_data(form=form, **kwargs) 308 308 if self.steps.current == 'my_step_name': 309 309 context.update({'another_var': True}) 310 310 return context … … 431 431 432 432 def render(self, form=None, **kwargs): 433 433 form = form or self.get_form() 434 context = self.get_context_data(form , **kwargs)434 context = self.get_context_data(form=form, **kwargs) 435 435 return self.render_to_response(context) 436 436 437 437 Providing initial data for the forms -
django/contrib/formtools/wizard/views.py
535 535 Returns a ``HttpResponse`` containing all needed context data. 536 536 """ 537 537 form = form or self.get_form() 538 context = self.get_context_data(form , **kwargs)538 context = self.get_context_data(form=form, **kwargs) 539 539 return self.render_to_response(context) 540 540 541 541 def done(self, form_list, **kwargs): … … 683 683 A NamedUrlFormWizard with pre-configured CookieStorageBackend. 684 684 """ 685 685 storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' 686 -
django/contrib/formtools/tests/wizard/wizardtests/tests.py
1 1 from __future__ import with_statement 2 2 import os 3 3 4 from django import forms 4 5 from django.test import TestCase 6 from django.test.client import RequestFactory 5 7 from django.conf import settings 6 8 from django.contrib.auth.models import User 9 from django.contrib.formtools.wizard.views import CookieWizardView 7 10 8 11 9 12 class WizardTests(object): … … 280 283 TEMPLATE_DIRS=list(settings.TEMPLATE_DIRS) + [templates]): 281 284 response = self.client.get(self.wizard_url) 282 285 self.assertTemplateUsed(response, 'other_wizard_form.html') 286 287 288 class WizardTestGenericViewInterface(TestCase): 289 290 def test_get_context_data(self): 291 class TestWizard(CookieWizardView): 292 """ 293 A subclass that implements ``get_context_data`` using the standard 294 protocol for generic views (accept only **kwargs). 295 296 See ticket #17148. 297 """ 298 def get_context_data(self, **kwargs): 299 return super(TestWizard, self).get_context_data(**kwargs) 300 301 factory = RequestFactory() 302 view = TestWizard.as_view([forms.Form]) 303 view(factory.get('/')) -
django/contrib/formtools/tests/wizard/__init__.py
14 14 SessionWizardTests, 15 15 CookieWizardTests, 16 16 WizardTestKwargs, 17 WizardTestGenericViewInterface, 17 18 )