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].
Note:
See TracTickets
for help on using tickets.
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}}}.