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

Create and add inlines in 'same' time #121

Open
hbrunacci opened this issue Aug 22, 2019 · 1 comment
Open

Create and add inlines in 'same' time #121

hbrunacci opened this issue Aug 22, 2019 · 1 comment

Comments

@hbrunacci
Copy link

hi, To be able to load data in the inline at the same time, I created an item I did this little trick. Is it ok or can it bring another complication?
Basically what it does is forward to 'edit' url instead of 'list' url before success.


def get_create_view(self):
        CreateViewClass = super(Orden_TrabajoCRUD, self).get_create_view()

        class CreateView(CreateViewClass):
            inlines = self.inlines

            def get_success_url(self):
                url = super(CreateView, self).get_success_url()
                if self.inlines:
                    url_list = url.split('/')
                    url_list[url_list.index('list')] = str(self.object.id)
                    url = '/'.join(url_list) + '/update'
                return url

        return CreateView
@oscarmlage
Copy link
Owner

Apart from the hardcoded Orden_TrabajoCRUD reference, the code seems to be correct but I need some context to test it and see if it can be added as feature. A new setting that let the user choose between edit or list as the success_url would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants