Opened 17 years ago

Closed 17 years ago

#5919 closed (fixed)

6655 formset update makes adding imposible (when model have inlines)

Reported by: LongMan <alx.gsv@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: inline add
Cc: alx.gsv@…, akaihol+djtick@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

From 6654 to 6655 there were changes in the branch:

U    django/newforms/models.py
A    tests/modeltests/model_formsets
A    tests/modeltests/model_formsets/__init__.py
A    tests/modeltests/model_formsets/models.py

Since 6655 i can't add new objects of models that have inlines options. When options without intlines it is all right.
Error is:

TypeError at /admin/gmaps/point/add/
__init__() takes at least 2 arguments (1 given)
Request Method: 	GET
Request URL: 	http://localhost:8000/admin/gmaps/point/add/
Exception Type: 	TypeError
Exception Value: 	__init__() takes at least 2 arguments (1 given)
Exception Location: 	/home/longman/django-svn/newforms-admin/django/contrib/admin/options.py in add_view, line 505
Python Executable: 	/usr/bin/python
Python Version: 	2.5.1

Traceback:

Traceback (most recent call last):
File "/home/longman/django-svn/newforms-admin/django/core/handlers/base.py" in _real_get_response
  81. response = callback(request, *callback_args, **callback_kwargs)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/sites.py" in root
  136. return self.model_page(request, *url.split('/', 2))
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/sites.py" in model_page
  153. return admin_obj(request, rest_of_url)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/options.py" in __call__
  251. return self.add_view(request)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/options.py" in add_view
  505. inline_formset = FormSet()

  TypeError at /admin/gmaps/point/add/
  __init__() takes at least 2 arguments (1 given)

Attachments (1)

09-inline-parent-instance.diff (566 bytes ) - added by Petr Marhoun <petr.marhoun@…> 17 years ago.

Download all attachments as: .zip

Change History (6)

by Petr Marhoun <petr.marhoun@…>, 17 years ago

comment:1 by LongMan <alx.gsv@…>, 17 years ago

Resolution: worksforme
Status: newclosed

comment:2 by Petr Marhoun <petr.marhoun@…>, 17 years ago

Has patch: set
Resolution: worksforme
Status: closedreopened

I think this ticket should not be closed - it is not fixed in django.

This code from django.contrib.admin.ModelAdmin.add_view is problematic:

      if request.method == 'POST':
            form = ModelForm(request.POST, request.FILES)
            for FormSet in self.formsets_add(request):
                inline_formset = FormSet(data=request.POST, files=request.FILES)
                inline_formsets.append(inline_formset)
            # ...
        else:
            form = ModelForm(initial=request.GET)
            for FormSet in self.formsets_add(request):
                inline_formset = FormSet()
                inline_formsets.append(inline_formset)

It is not compatible with django.newforms.models.InlineFormset:

class InlineFormset(BaseModelFormSet): 
    """A formset for child objects related to a parent.""" 
    def __init__(self, instance, data=None, files=None): 
        # ...

comment:3 by Antti Kaihola, 17 years ago

Cc: akaihol+djtick@… added

I agree with Petr, this is still broken in #6718. (As a sidenote, the patch for #5828 which fixes saving for inlines has no effect on this bug.)

comment:4 by Brian Rosner, 17 years ago

Yes, this is an issue with current revision of newforms-admin. It was discussed slightly in #5895 with a correct solution. However, this ticket is the correct place for patches and further comments about the issue.

comment:5 by jkocherhans, 17 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in [6836].

Note: See TracTickets for help on using tickets.
Back to Top