Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#2243 closed defect (fixed)

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

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

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@… 18 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@… 18 years ago.
Updated version of patch, now everything works correctly

Download all attachments as: .zip

Change History (8)

comment:1 by dolemite@…, 18 years ago

priority: normalhigh

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

by yk4ever@…, 18 years ago

Attachment: django_2243.patch added

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

by yk4ever@…, 18 years ago

Attachment: django_2243b.patch added

Updated version of patch, now everything works correctly

comment:2 by yk4ever@…, 18 years ago

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

provided a patch

comment:3 by marcdm.NOSPAM@…, 18 years ago

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

comment:4 by rbemrose@…, 17 years ago

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

comment:5 by Russell Keith-Magee, 17 years ago

Resolution: fixed
Status: newclosed

(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 by Russell Keith-Magee, 17 years ago

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

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