Coder Social home page Coder Social logo

Comments (9)

specialunderwear avatar specialunderwear commented on August 23, 2024

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:

class BottomInline(LinkInline):
    model = models.Bottom
    fields = ('top',)

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
I don;t know why the fields are empty. That is a bug. Please try again with the definition of BottomInline as follows:

class BottomInline(LinkInline):
    model = models.Bottom
    fields = ('top', 'text')

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 fields

from django-easymode.

specialunderwear avatar specialunderwear commented on August 23, 2024

The documentation also says you MUST define the fields property

class BottomLinkInline(LinkInline):
    """
    This is the inline view of the inlined item. It will de rendered as a
    link to the change view or add view of the inlined item.

    NOTE that you MUST define fields, which must only include the foreign key.
    Ofcourse you might want to include some more fields and put them as
    read_only_fields, to give a bit more info.
    """
    fields = ('top',)
    model = BottomModel

from django-easymode.

nnseva avatar nnseva commented on August 23, 2024

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

from django-easymode.

specialunderwear avatar specialunderwear commented on August 23, 2024

If you add 'text' to readonly_fields does that work? Or is it still empty?

class BottomInline(LinkInline):
model = models.Bottom
fields = ('top', )
readonly_fields = ('text',)

from django-easymode.

nnseva avatar nnseva commented on August 23, 2024

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',)

from django-easymode.

specialunderwear avatar specialunderwear commented on August 23, 2024

Ok so the documentation should be updated to reflect this.

from django-easymode.

nnseva avatar nnseva commented on August 23, 2024

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.

from django-easymode.

specialunderwear avatar specialunderwear commented on August 23, 2024

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.

See http://stackoverflow.com/questions/896153/how-to-show-hidden-autofield-in-django-formset/1266682#1266682

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.

from django-easymode.

nnseva avatar nnseva commented on August 23, 2024

Hmm ... it is really near to my needs, including polymorphing, I should investigate it deeply ...

from django-easymode.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.