Opened 10 years ago

Closed 9 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: UI/UX:


From 6654 to 6655 there were changes in the branch:

U    django/newforms/
A    tests/modeltests/model_formsets
A    tests/modeltests/model_formsets/
A    tests/modeltests/model_formsets/

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/ in add_view, line 505
Python Executable: 	/usr/bin/python
Python Version: 	2.5.1


Traceback (most recent call last):
File "/home/longman/django-svn/newforms-admin/django/core/handlers/" in _real_get_response
  81. response = callback(request, *callback_args, **callback_kwargs)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/" in root
  136. return self.model_page(request, *url.split('/', 2))
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/" in model_page
  153. return admin_obj(request, rest_of_url)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/" in __call__
  251. return self.add_view(request)
File "/home/longman/django-svn/newforms-admin/django/contrib/admin/" 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@…> 10 years ago.

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by Petr Marhoun <petr.marhoun@…>

comment:1 Changed 10 years ago by LongMan <alx.gsv@…>

Resolution: worksforme
Status: newclosed

comment:2 Changed 10 years ago by Petr Marhoun <petr.marhoun@…>

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)
            # ...
            form = ModelForm(initial=request.GET)
            for FormSet in self.formsets_add(request):
                inline_formset = 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 Changed 10 years ago by Antti Kaihola

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 Changed 10 years ago by Brian Rosner

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 Changed 9 years ago by jkocherhans

Resolution: fixed
Status: reopenedclosed

Fixed in [6836].

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