Opened 19 years ago

Closed 19 years ago

#1359 closed defect (fixed)

magic-removal: error on save with a model containing a ManyToManyField.

Reported by: matt Owned by: Adrian Holovaty
Component: contrib.admin Version: magic-removal
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Given a simple model with a ManyToMany relation to User:

from django.db import models
from django.contrib.auth.models import User

class Note(models.Model):
    title = models.CharField(maxlength=200)
    pub_date = models.DateTimeField()
    note = models.TextField()
    users = models.ManyToManyField(User)
    
    class Admin:
        list_display=('title', 'pub_date')

When saving in the admin, the following error occurs:

AttributeError at /admin/merlin/note/add/
'Note' object has no attribute 'set_users'
Request Method:  	POST
Request URL: 	http://127.0.0.1:8000/admin/merlin/note/add/
Exception Type: 	AttributeError
Exception Value: 	'Note' object has no attribute 'set_users'
Exception Location: 	/Users/mcroydon/django/django_magic/django/db/models/manipulators.py in save, line 121

If I add raw_id_admin=True to the users field, a different error is thrown:

AttributeError at /admin/merlin/note/add/
Options instance has no attribute 'get_model_module'
Request Method:  	POST
Request URL: 	http://127.0.0.1:8000/admin/merlin/note/add/
Exception Type: 	AttributeError
Exception Value: 	Options instance has no attribute 'get_model_module'
Exception Location: 	/Users/mcroydon/django/django_magic/django/db/models/fields/related.py in isValidIDList, line 473

This applies to the magic-removal branch as of [2307].

Change History (3)

comment:1 by matt, 19 years ago

Despite the errors, the notes are being added to the database in the first case, but are not being added if {{raw_id_admin=True}}}.

comment:2 by matt, 19 years ago

Pending patches in #1372 fix this issue, this ticket can be closed when the patches from #1372 are rolled in to magic-removal.

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

Fixed in [2374].

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