Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added a prefix attribute to django.views.generic.edit.FormMixin. #477

Closed
wants to merge 1 commit into from

3 participants

Ivan Bustamante Marc Tamlyn Florian Apolloner
Ivan Bustamante

Also added a get_prefix() method. Modified get_form_kwargs() method, in order to include the prefix in form kwargs.

Ivan Bustamante Added a prefix attribute to django.views.generic.edit.FormMixin. Also…
… added a get_prefix() method. Modified get_form_kwargs() method, in order to include the prefix in form kwargs.
eb16663
Marc Tamlyn
Owner

Will need docs and tests.

Florian Apolloner
Owner

As @mjtamlyn noted: This patch misses docs and tests - I'll close this for now.

Florian Apolloner apollo13 closed this November 03, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 28, 2012
Ivan Bustamante Added a prefix attribute to django.views.generic.edit.FormMixin. Also…
… added a get_prefix() method. Modified get_form_kwargs() method, in order to include the prefix in form kwargs.
eb16663
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 0 deletions. Show diff stats Hide diff stats

  1. 10  django/views/generic/edit.py
10  django/views/generic/edit.py
@@ -14,12 +14,19 @@ class FormMixin(ContextMixin):
14 14
     initial = {}
15 15
     form_class = None
16 16
     success_url = None
  17
+    prefix = None
17 18
 
18 19
     def get_initial(self):
19 20
         """
20 21
         Returns the initial data to use for forms on this view.
21 22
         """
22 23
         return self.initial.copy()
  24
+    
  25
+    def get_prefix(self):
  26
+        """
  27
+        Returns the prefix to use for forms on this view
  28
+        """
  29
+        return self.prefix
23 30
 
24 31
     def get_form_class(self):
25 32
         """
@@ -38,6 +45,9 @@ def get_form_kwargs(self):
38 45
         Returns the keyword arguments for instantiating the form.
39 46
         """
40 47
         kwargs = {'initial': self.get_initial()}
  48
+        prefix = self.get_prefix()
  49
+        if prefix:
  50
+            kwargs.update({'prefix': prefix,})
41 51
         if self.request.method in ('POST', 'PUT'):
42 52
             kwargs.update({
43 53
                 'data': self.request.POST,
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.