Django

Code

Ticket #5919 (closed: fixed)

Opened 10 months ago

Last modified 9 months ago

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

Reported by: LongMan <alx.gsv@gmail.com> Assigned to: nobody
Milestone: Component: Admin interface
Version: newforms-admin Keywords: inline add
Cc: alx.gsv@gmail.com, akaihol+djtick@ambitone.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

09-inline-parent-instance.diff (0.6 kB) - added by Petr Marhoun <petr.marhoun@gmail.com> on 11/11/07 07:56:54.

Change History

11/11/07 07:56:54 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • attachment 09-inline-parent-instance.diff added.

11/13/07 07:53:19 changed by LongMan <alx.gsv@gmail.com>

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to worksforme.
  • needs_tests changed.
  • needs_docs changed.

11/15/07 21:54:05 changed by Petr Marhoun <petr.marhoun@gmail.com>

  • status changed from closed to reopened.
  • has_patch set to 1.
  • resolution deleted.

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): 
        # ...

11/26/07 11:35:39 changed by akaihola

  • cc changed from alx.gsv@gmail.com to alx.gsv@gmail.com, akaihol+djtick@ambitone.com.

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.)

11/26/07 12:02:56 changed by brosner

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.

12/02/07 12:15:16 changed by jkocherhans

  • status changed from reopened to closed.
  • resolution set to fixed.

Fixed in [6836].


Add/Change #5919 (6655 formset update makes adding imposible (when model have inlines))




Change Properties
Action