Skip to content
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

Support 'fields' on the ModelAdmin class for non-Page models #6

Open
ababic opened this issue Jun 20, 2016 · 5 comments
Open

Support 'fields' on the ModelAdmin class for non-Page models #6

ababic opened this issue Jun 20, 2016 · 5 comments

Comments

@ababic
Copy link

ababic commented Jun 20, 2016

This would be reasonably simple to implement into the modeladmin app, but it wouldn't be possible right now to pick those panel definitions up in other views, such as for use in InlinePanels etc.

Maybe this is a discussion for a separate thread, but maybe if we moved toward a django-like approach, where there'd be a central registry of models and their ModelAdmin classes, so configuration like that could be picked up?

I think it would also be sensible to support fields and exclude attributes (maybe using different names?) on the ModelAdmin class. I know our aim isn't to fully support every feature of Django ModelAdmin, and the line must be drawn somewhere, but to save developers from having to import and a bunch of edit handlers and write full definitions, just to change field order or exclude a couple of fields, I think would be a nice feature.

Any thoughts?

@theju
Copy link

theju commented Jun 20, 2016

Sounds like a good idea.

Some of the cases for customizing the modeladmin that I can think of are:

@ababic
Copy link
Author

ababic commented Jun 20, 2016

Thanks for the input @theju.

In regards to custom validation, we at RKH have found that overriding the clean and save methods on the model itself is often the most reliable way to achieve such things when working with Wagtail (it works for page-type models, too!). I suppose it depends on what you're trying to achieve, though.

@gasman
Copy link
Contributor

gasman commented May 15, 2018

'exclude' behaviour is implemented (as the form_fields_exclude attribute) as of wagtail/wagtail#3295; leaving this issue open for the remaining proposals ('fields' / 'include_fields', and specifying a panel definition on the ModelAdmin class).

@DzMkh
Copy link

DzMkh commented Nov 18, 2018

@gasman Hi,
Is it possible somehow to exclude fields from form for Page-models depending on some conditions?

Right now I have only 1 solution:

class NewFieldPanel(FieldPanel):
    def bind_to_instance(self, instance=None, form=None, request=None):
        form.fields['managers'].widget = HiddenInput()
        new = super().bind_to_instance(
            instance=instance, form=form, request=request
        )
        return new

Bu it only hides input instead of removing field panel at all. I need somehow override exclude in Meta.

@laymonage
Copy link
Collaborator

Support for panels and edit_handler were added in wagtail/wagtail#4900, so only fields/include_fields is remaining.

However, as per wagtail/rfcs#85, I'm transferring this issue to the wagtail-modeladmin repository.

@laymonage laymonage changed the title Support panel definitions, 'fields' and 'exclude' on the ModelAdmin class for non-Page models Support 'fields' on the ModelAdmin class for non-Page models Jul 26, 2023
@gasman gasman transferred this issue from wagtail/wagtail Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants