Ticket #17148: 17148.diff

File 17148.diff, 3.6 KB (added by Bradley Ayers <bradley.ayers@…>, 13 years ago)
  • docs/ref/contrib/formtools/form-wizard.txt

     
    304304    Example to add extra variables for a specific step::
    305305
    306306        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)
    308308            if self.steps.current == 'my_step_name':
    309309                context.update({'another_var': True})
    310310            return context
     
    431431
    432432        def render(self, form=None, **kwargs):
    433433            form = form or self.get_form()
    434             context = self.get_context_data(form, **kwargs)
     434            context = self.get_context_data(form=form, **kwargs)
    435435            return self.render_to_response(context)
    436436
    437437Providing initial data for the forms
  • django/contrib/formtools/wizard/views.py

     
    535535        Returns a ``HttpResponse`` containing all needed context data.
    536536        """
    537537        form = form or self.get_form()
    538         context = self.get_context_data(form, **kwargs)
     538        context = self.get_context_data(form=form, **kwargs)
    539539        return self.render_to_response(context)
    540540
    541541    def done(self, form_list, **kwargs):
     
    683683    A NamedUrlFormWizard with pre-configured CookieStorageBackend.
    684684    """
    685685    storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
    686 
  • django/contrib/formtools/tests/wizard/wizardtests/tests.py

     
    11from __future__ import with_statement
    22import os
    33
     4from django import forms
    45from django.test import TestCase
     6from django.test.client import RequestFactory
    57from django.conf import settings
    68from django.contrib.auth.models import User
     9from django.contrib.formtools.wizard.views import CookieWizardView
    710
    811
    912class WizardTests(object):
     
    280283                TEMPLATE_DIRS=list(settings.TEMPLATE_DIRS) + [templates]):
    281284            response = self.client.get(self.wizard_url)
    282285            self.assertTemplateUsed(response, 'other_wizard_form.html')
     286
     287
     288class 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

     
    1414    SessionWizardTests,
    1515    CookieWizardTests,
    1616    WizardTestKwargs,
     17    WizardTestGenericViewInterface,
    1718)
Back to Top