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

How do you use @choice? Can you provide a working example? #19

Open
tvanesse opened this issue Jan 16, 2024 · 0 comments
Open

How do you use @choice? Can you provide a working example? #19

tvanesse opened this issue Jan 16, 2024 · 0 comments

Comments

@tvanesse
Copy link
Contributor

I guess the title is self-explanatory. There is no example for this decorator in the documentation.

I've tried something like

    @view(label="VIEW 1")
    def select_view_button(self, request, obj=None):
        # Implement any logic you need
        return HttpResponse("Selected view button clicked!")

    @view(label="VIEW 2")
    def select_view_button2(self, request, obj=None):
        # Implement any logic you need
        return HttpResponse("Selected view 2 button clicked!")

    @choice(
        label="Select View",
        choices=[select_view_button, select_view_button2],
        change_form=True,
        change_list=False,
    )
    def group_views(self, request, obj=None):
        # Implement any logic you need
        return HttpResponse("Selected view button clicked!")

But it keeps complaining that 'ChoiceButton' object has no attribute 'choices'.

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

1 participant