-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect LinkInline behaviour #3
Comments
Ok, yeah what you need to do is, define the fields property on the admin for the BottomInline. You should only include the foreign key. In your case it should look like:
The parent_link should not be used in the BottomInline, only in the BottomAdmin. http://packages.python.org/django-easymode/tree/api.html#easymode.tree.admin.abstract.LinkInline
But again, you should not show the fields in that form, only the links should be visible. So only the foreign key should be in |
The documentation also says you MUST define the fields property
|
Explicit definition of the 'fields' property doesn't help. Definitely, the BottomInline works as described if I include the only 'top' field (foreign key) to the 'fields' property, but this is not an expected behaviour for the inline form inherited from the standard django inline :( Really I wanted to have a standard django inline (probably readonly) with additional link to the full-featured (sub)object editor. The str() representation of the (sub)object helps partially, but is not a complete solution if I f.e. wanted to have a table of (sub)object rows. I will think about it ... |
If you add 'text' to readonly_fields does that work? Or is it still empty? class BottomInline(LinkInline): |
It doesn't work (the 'text' is not shown at all) in this form, but the following is working as expected: class BottomInline(LinkInline):
model = models.Bottom
parent_link = 'top'
fields = ('top','text')
readonly_fields = ('text',) |
Ok so the documentation should be updated to reflect this. |
It might be useful to have a separate object like 'object link widget' which I can add to the standard (or inherited from standard) tabular or stacked inline ... this solution will cover all needs. |
Hmm the problem is, that django overrides every attempt to have a custom widget for a the foreign key field in inlines. That is why LinkInline has a custom formset, to stop django from resetting it to it's default. So what you are proposing is not possible. You always have to override the formset. Maybe what you want is what I'm doing in: https://github.com/specialunderwear/django-polymorphic-easymode/blob/master/mixed/admin.py It also renders a link to the 'full' admin. |
Hmm ... it is really near to my needs, including polymorphing, I should investigate it deeply ... |
For some reason, the LinkInline doesn't show inline objects except the first one.
I've created a very simple example with two models:
and created a simple admin for them:
The first (uncommented) portion of the admin is working with easymode, while the second one (commented out) is a standard django admin code.
I am filling in one Top object and several Bottom objects linked to the Top one. When I am looking to the standard admin, I see several filled objects:
https://docs.google.com/open?id=0B6V0N4fDeXFPNjJjZGExMDMtNjk5Yi00NzZiLWE2MjctZDVjNjE5OWRlNDM4
When I am looking to the easymode-powered admin, I see the only one Bottom object filled, but several object lines with links (links are working):
https://docs.google.com/open?id=0B6V0N4fDeXFPYzM5MGZlMGItNjExYi00MGRhLTkwMjUtYjEwZDViZGEwNTU5
The text was updated successfully, but these errors were encountered: