Code

Opened 8 years ago

Closed 8 years ago

#1359 closed defect (fixed)

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

Reported by: matt Owned by: adrian
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: UI/UX:

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

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by matt

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 Changed 8 years ago by matt

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 Changed 8 years ago by adrian

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

Fixed in [2374].

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.