Skip to content

Commit

Permalink
Fix #114: Directly pass 'fields' to Django
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashaag committed Dec 10, 2015
1 parent 4c21ee6 commit 210dabe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
6 changes: 0 additions & 6 deletions extra_views/advanced.py
Expand Up @@ -80,9 +80,6 @@ def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates a blank version of the form and formsets.
"""
if django.VERSION >= (1, 6) and self.fields is None and self.form_class is None:
self.fields = '__all__' # backward compatible with older versions

form_class = self.get_form_class()
form = self.get_form(form_class)
inlines = self.construct_inlines()
Expand All @@ -93,9 +90,6 @@ def post(self, request, *args, **kwargs):
Handles POST requests, instantiating a form and formset instances with the passed
POST variables and then checked for validity.
"""
if django.VERSION >= (1, 6) and self.fields is None and self.form_class is None:
self.fields = '__all__' # backward compatible with older versions

form_class = self.get_form_class()
form = self.get_form(form_class)

Expand Down
8 changes: 1 addition & 7 deletions extra_views/formsets.py
Expand Up @@ -80,7 +80,7 @@ def get_formset_kwargs(self):
initial = self.get_initial()
if initial:
kwargs['initial'] = initial

if self.prefix:
kwargs['prefix'] = self.prefix

Expand Down Expand Up @@ -179,9 +179,6 @@ def get_factory_kwargs(self):
Returns the keyword arguments for calling the formset factory
"""
kwargs = super(ModelFormSetMixin, self).get_factory_kwargs()
if django.VERSION >= (1, 6) and self.fields is None:
self.fields = '__all__' # backward compatible with older versions

kwargs.update({
'exclude': self.exclude,
'fields': self.fields,
Expand Down Expand Up @@ -256,9 +253,6 @@ def get_factory_kwargs(self):
Returns the keyword arguments for calling the formset factory
"""
kwargs = super(BaseInlineFormSetMixin, self).get_factory_kwargs()
if django.VERSION >= (1, 6) and self.fields is None:
self.fields = '__all__' # backward compatible with older versions

kwargs.update({
'exclude': self.exclude,
'fields': self.fields,
Expand Down
7 changes: 0 additions & 7 deletions extra_views_tests/tests.py
Expand Up @@ -166,7 +166,6 @@ def test_save(self):
'items-0-name': 'Bubble Bath',
'items-0-sku': '1234567890123',
'items-0-price': D('9.99'),
'items-0-order': order.id,
'items-0-status': 0,
'items-1-DELETE': True,
}
Expand Down Expand Up @@ -264,7 +263,6 @@ def test_create(self):
'items-0-sku': '1234567890123',
'items-0-price': D('9.99'),
'items-0-status': 0,
'items-0-order': '',
'items-1-DELETE': True,
'extra_views_tests-tag-content_type-object_id-TOTAL_FORMS': 2,
'extra_views_tests-tag-content_type-object_id-INITIAL_FORMS': 0,
Expand Down Expand Up @@ -296,12 +294,10 @@ def test_validation(self):
'items-0-sku': '',
'items-0-price': '',
'items-0-status': 0,
'items-0-order': '',
'items-1-name': '',
'items-1-sku': '',
'items-1-price': '',
'items-1-status': '',
'items-1-order': '',
'items-1-DELETE': True,
'extra_views_tests-tag-content_type-object_id-TOTAL_FORMS': 2,
'extra_views_tests-tag-content_type-object_id-INITIAL_FORMS': 0,
Expand Down Expand Up @@ -344,19 +340,16 @@ def test_update(self):
'items-0-sku': '1234567890123',
'items-0-price': D('9.99'),
'items-0-status': 0,
'items-0-order': order.id,
'items-0-id': item_ids[0],
'items-1-name': 'Bubble Bath',
'items-1-sku': '1234567890123',
'items-1-price': D('9.99'),
'items-1-status': 0,
'items-1-order': order.id,
'items-1-id': item_ids[1],
'items-2-name': 'Bubble Bath',
'items-2-sku': '1234567890123',
'items-2-price': D('9.99'),
'items-2-status': 0,
'items-2-order': order.id,
'items-3-DELETE': True,
'extra_views_tests-tag-content_type-object_id-TOTAL_FORMS': 3,
'extra_views_tests-tag-content_type-object_id-INITIAL_FORMS': 1,
Expand Down
3 changes: 3 additions & 0 deletions extra_views_tests/views.py
Expand Up @@ -22,6 +22,7 @@ class AddressFormSetViewNamed(NamedFormsetsMixin, AddressFormSetView):

class ItemModelFormSetView(ModelFormSetView):
model = Item
fields = ['name', 'sku', 'price', 'order', 'status']
template_name = 'extra_views/item_formset.html'


Expand All @@ -34,6 +35,7 @@ class FormAndFormSetOverrideView(ModelFormSetView):

class OrderItemFormSetView(InlineFormSetView):
model = Order
fields = ['name', 'sku', 'price', 'order', 'status']
inline_model = Item
template_name = "extra_views/inline_formset.html"

Expand All @@ -56,6 +58,7 @@ class TagsInline(GenericInlineFormSet):

class OrderCreateView(CreateWithInlinesView):
model = Order
fields = ['name']
context_object_name = 'order'
inlines = [ItemsInline, TagsInline]
template_name = 'extra_views/order_and_items.html'
Expand Down

0 comments on commit 210dabe

Please sign in to comment.