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

django-object-actions not compatible with django-import-export #67

Open
platzhersh opened this issue Jun 20, 2016 · 6 comments
Open

django-object-actions not compatible with django-import-export #67

platzhersh opened this issue Jun 20, 2016 · 6 comments

Comments

@platzhersh
Copy link

platzhersh commented Jun 20, 2016

Has anyone ever tried to use django object actions together with django import export?

I have a admin class that I would like to use both of these together:

class MyClass(DjangoObjectActions, ImportExportMixin, SimpleHistoryAdmin):

Like this, I can see my django object actions, but none of the Django import export actions in the admin.
When I change to this:

class MyClass(ImportExportMixin, DjangoObjectActions, SimpleHistoryAdmin):

I see my import export buttons but none of my django object actions anymore.

@crccheck
Copy link
Owner

I suspect it's because both of us are attempting to use a custom template. I could have sworn I documented what to do in this situation, but I can't find it.

In this case, you'd have to make your own change_form.html and construct it to have all the elements you need.

@andybak
Copy link
Contributor

andybak commented Jul 17, 2016

Could we make it a bit simpler to customize the templates? Rather than having to copy in 13 lines from your template - use an include or a templatetag so that all people have to do is add: {% include 'object_actions' %} (or {% object_actions %} if you go with an inclusion tag)

@crccheck
Copy link
Owner

haha, I was going to say you can check out #17 but that's your PR. It's come up in other ways too so I'm leaning back towards supporting an include tag. I could have sworn there was documentation for how to customize the template but I couldn't find it the last time I looked. I'd like this to be simple enough where everything fits in the README but it's looking like that's not happening.

@andybak
Copy link
Contributor

andybak commented Sep 5, 2016

Quick workaround I used just now that specifically fixes this for Django Import/Export:

  1. Ensure DjangoObjectActions is before ExportMixin in your ModelAdmin class declaration
  2. Add 'redirect_to_export' to your changelist_actions
  3. Add the following method to your ModelAdmin
    def redirect_to_export(self, request, obj):
        return HttpResponseRedirect(reverse('admin:%s_%s_export' % self.get_model_info()))
    redirect_to_export.label = "Export"

This works for Export but it should be clear how to do the same for import

EDIT - Damn - the redirect loses the queryset so you can't export filtered result sets. I'll think up an improved way to do this.

@MarthinusBosman
Copy link

Any progress made on this so far?

@ahmedsafadii
Copy link

same issue

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