Django

Code

Ticket #2243 (closed: fixed)

Opened 4 years ago

Last modified 3 years ago

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

Reported by: dolemite@wuli.nu Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

django_2243.patch (4.2 kB) - added by yk4ever@gmail.com on 07/30/06 12:25:38.
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@gmail.com on 07/30/06 15:53:02.
Updated version of patch, now everything works correctly

Change History

06/27/06 11:14:19 changed by dolemite@wuli.nu

  • priority changed from normal to high.

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

07/30/06 12:25:38 changed by yk4ever@gmail.com

  • attachment django_2243.patch added.

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

07/30/06 15:53:02 changed by yk4ever@gmail.com

  • attachment django_2243b.patch added.

Updated version of patch, now everything works correctly

08/01/06 05:57:52 changed by yk4ever@gmail.com

  • 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

09/01/06 19:19:23 changed by marcdm.NOSPAM@REMOVE.phronein.com

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

09/22/06 17:52:47 changed by rbemrose@vgmusic.com

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

09/25/06 09:06:14 changed by russellm

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

(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@wuli.nu and coconutstudio@yahoo.com for the original reports, Tyson Tate for a clean test case, and Jay Parlar for helping out with a solution.

09/26/06 07:53:15 changed by russellm

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


Add/Change #2243 ([patch] admin tries to set M2M inside a reverse foreign key)




Change Properties
Action