Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#1330 closed defect (fixed)

[magic-removal] edit_inline completely broken

Reported by: Tom Tobin <korpios@…> Owned by: Jacob
Component: Core (Other) Version: magic-removal
Severity: major Keywords:
Cc: cmlenz@…, david.ascher@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


When attempting to set a ForeignKey to edit_inline=models.TABULAR in magic-removal (r2279), I get the following error:

Exception Type: 	AttributeError
Exception Value: 	'RelatedObject' object has no attribute 'get_manipulator_fields'
Exception Location: 	/home/korpios/devel/py3p/django/db/models/ in __init__, line 73

It appears that RelatedObjects are built in the get_all_related_objects method of django.db.models.options.Options; these are returned when the __init__ method of django.db.models.manipulators.AutomaticManipulator calls get_all_related_objects. Subsequently in the manipulator code, however, it expects such a RelatedObject to have a get_manipulator_fields method as if it were a subclass of Field (or mimicking one in part). Attempting to simply redirect such calls to the RelatedObject's field attribute results in further failures down the line (e.g., expecting a get_list method).

Going back to trunk, it seems that RelatedObject has these methods; I'm not sure with what code the fault lies here in magic-removal (i.e., with RelatedObject or AutomaticManipulator), so I'll defer to someone with more experience in this particular area.

Attachments (1)

django_edit_inline.diff (23.4 KB) - added by Christopher Lenz <cmlenz@…> 11 years ago.
Patch that restores edit_inline functionality to state in trunk

Download all attachments as: .zip

Change History (13)

comment:1 Changed 11 years ago by anonymous

Cc: cmlenz@… added

comment:2 Changed 11 years ago by anonymous

This still appears to be an issue in [2307] with edit_inline (in my case models.TABULAR).

comment:3 Changed 11 years ago by Antti Kaihola

Same error in [2433] with a very basic model with one SlugField and three CharFields. Happens when I try to add an object in admin.

comment:4 Changed 11 years ago by akaihola <antti.kaihola@…>

Narrowing in: I get this error in admin only when trying to add objects for models which are used as a ForeignKey in another model.

comment:5 Changed 11 years ago by Antti Kaihola

get_manipulator_fields() was removed from class RelatedObject in [1769].

comment:6 Changed 11 years ago by Antti Kaihola

Correction: this problem hits me only if I use edit_inline. Anyway, Jacob seems to have a hold of it so I'll stop babbling here.

comment:7 Changed 11 years ago by anonymous

Cc: david.ascher@… added

Changed 11 years ago by Christopher Lenz <cmlenz@…>

Attachment: django_edit_inline.diff added

Patch that restores edit_inline functionality to state in trunk

comment:8 Changed 11 years ago by Christopher Lenz <cmlenz@…>

priority: normalhigh
Severity: normalmajor
Summary: [magic-removal] RelatedObject expected to have attributes of Field in manipulator code[magic-removal] edit_inline completely broken

I've attached a patch that fixes the edit_inline support on the magic-removal branch, so that the branch provides the same functionality as trunk. This mainly consisted of reverting a couple of changes to manipulators, formfields and the admin that were never completed. In particular, core fields and the xxx_num_in_admin options are added back. Sorry.

I suppose this is somewhat controversial. However: these changes are pretty minimal, and restore a fully-functioning (AFAICT, at least) edit_inline system. I'd very much appreciate if you guys checked this in and wrapped up the MR branch.

Other changes such as moving edit_inline to Dojo/AJAX, removing core fields, recursive manipulators and all that should have a working base to build on. Please :-P

comment:9 Changed 11 years ago by Jacob

Owner: changed from Adrian Holovaty to Jacob
Status: newassigned

Oh HELL yeah -- you're my hero, Christopher :)

I'm going to take a quick look at this and then roll it in. Keep in mind (for anyone who wants to hack on this) thatr the API will likely change once the validator-aware-models changes get finished, but we need this to work for the time being.

comment:10 Changed 11 years ago by Christopher Lenz <cmlenz@…>

Cool, please let me know if you find any issues with the patch.

Forgot to add that there are a couple of lines that implement support for edit_inline for one-to-one relations.

comment:11 Changed 11 years ago by Jacob

Resolution: fixed
Status: assignedclosed

(In [2502]) magic-removal: fixed #1330: edit-inline works again on magic-removal. Note that the API will change *substantailly* before we're done (for example, this reintroduces core fields, which suck) but this at least gives us a place to start with.

Many many thanks for Christopher Lenz, my new hero.

comment:12 Changed 9 years ago by korpios

Reporter: changed from Tom Tobin <korpios@…> to Tom Tobin <korpios@…>
Note: See TracTickets for help on using tickets.
Back to Top