Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#2243 closed defect (fixed)

[patch] admin tries to set M2M inside a reverse foreign key

Reported by: dolemite@… Owned by: adrian
Component: contrib.admin Version: master
Severity: critical Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Traceback (most recent call last):
File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  54. return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  40. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in add_stage
  257. new_object = manipulator.save(new_data)
File "/usr/local/lib/python2.4/site-packages/django/db/models/manipulators.py" in save
  218. was_changed = getattr(new_rel_obj, 'set_%s' % f.name)(rel_new_data[f.attname])

  AttributeError at /sd/admin/vuln_crud/vulnerability/add/
  'Requirement' object has no attribute 'set_res' 
from django.db import models

class Resource(models.Model):
        name = models.CharField(maxlength=200)
        class Admin:
                pass
class Plan(models.Model):
        name = models.CharField(maxlength=200)
        class Admin:
                pass
class Requirement(models.Model):
        plan=models.ForeignKey(Plan,edit_inline=models.TABULAR)
        res = models.ManyToManyField(Resource)
        name = models.CharField(maxlength=200,core=True)

Attachments (2)

django_2243.patch (4.2 KB) - added by yk4ever@… 8 years ago.
Fixes 2243; modifies raw_id_admin fields to behave more like common ones; shoos some minor bug
django_2243b.patch (5.4 KB) - added by yk4ever@… 8 years ago.
Updated version of patch, now everything works correctly

Download all attachments as: .zip

Change History (8)

comment:1 Changed 8 years ago by dolemite@…

  • priority changed from normal to high

I should say this happens when I attempt to add a new plan through the admin interface.

Changed 8 years ago by yk4ever@…

Fixes 2243; modifies raw_id_admin fields to behave more like common ones; shoos some minor bug

Changed 8 years ago by yk4ever@…

Updated version of patch, now everything works correctly

comment:2 Changed 8 years ago by yk4ever@…

  • Summary changed from admin tries to set M2M inside a reverse foreign key to [patch] admin tries to set M2M inside a reverse foreign key

provided a patch

comment:3 Changed 8 years ago by marcdm.NOSPAM@…

I applied this patch, and it seems to be working well. It definetly solved the M2M problem in the admin.

comment:4 Changed 8 years ago by rbemrose@…

I also applied this patch and it fixed the problem I was having with edit_inline and M2M. Thanks!

comment:5 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [3830]) Fixes #1816, #2243 -- Removed a stale remnant of pre-magic removal code in manipulators that modify m2m object that are edited inline. Thanks to dolemite@… and coconutstudio@… for the original reports, Tyson Tate for a clean test case, and Jay Parlar for helping out with a solution.

comment:6 Changed 8 years ago by russellm

(In [3858]) Refs #2243 -- Fixed manipulator handling of raw_id_admin m2m edit_inline fields.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.