2

I'm having trouble installing django-admin_action_mail from git.

I tried to install it via:

pip install
git+https://github.com/mjbrownie/django-admin_action_mail.git

But Django did not pick it up when I added it to settings.INSTALLED_APPS.

Did I miss something?

ggorlen
  • 44,755
  • 7
  • 76
  • 106
user2161049
  • 853
  • 1
  • 6
  • 13

1 Answers1

0

The admin code for that app is commented out (see here: https://github.com/mjbrownie/django-admin_action_mail/blob/master/admin_action_mail/admin.py ) so nothing is going to show up on the admin page - even if it's working and enabled.

It looks as though you need to create your own models to handle the mailing functions. Take a look at the README where it tells you to add something like the following in your app's admin.py:

from admin_action_mail.actions import mail_action

class MyModelAdmin(admin.ModelAdmin):

    #Note all args are optional
    actions = [
        mail_action(
            'description' : "Send Email to Related Users",
            'email_dot_path' : 'email', # dot path string to email field (eg 'user.email')
            'email_template_html' : 'admin_action_email/email.html'
            'reply_to' : 'noreply@example.com' # defaults to request.user.email
        )
    ]

admin.site.register(MyModel, MyModelAdmin)

Have you added a model like that to your own app's admin.py?

EDIT: As the problem appears to be with installation, the following should help:

You can add arbitrary paths to your wsgi path spec, that means it will pick up Python app modules in other locations. Assuming your app is installed in /home/user2161049/myapp you can put your external modules under /home/user2161049/myapp/external. In this case copy the contents of that app into /home/user2161049/myapp/external/admin_action_mail/.

To add this to your settings.py:

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(SITE_ROOT, 'external'))

The first line defines SITE_ROOT based on the current running script (setup.py) at startup. The second adds the external folder into the search path. You can put anything you want in there, and even define a specific folder somewhere else if you want to keep your externals out of your app folder. Restart the server and it should find the app just fine.

mfitzp
  • 15,275
  • 7
  • 50
  • 70
  • Yes, the problem is that the app was not installed properly. Django could not pick it up. – user2161049 Apr 30 '13 at 06:43
  • It's weird for it not to error in that case. Did you restart the server after making the changes to `setup.py`? – mfitzp Apr 30 '13 at 09:55
  • what changes to setup.py? I did couple of restarts to the server. – user2161049 Apr 30 '13 at 10:18
  • Adding it to the installed apps. Is it working now? You can always put the code where you like (I've always put external apps under a folder `/external` in the project folder) as long as it's in your Python/wsgi path. – mfitzp Apr 30 '13 at 10:37
  • no, its not on Python/wsgi path how can i add it? did you try to install this app? – user2161049 Apr 30 '13 at 10:40
  • 10x, it seems that Django did pick this app up but I had to copy the template folder to my project templates folder. – user2161049 Apr 30 '13 at 13:37
  • Again, that's a bit weird (it should find the template if the app is in the path and `django.template.loaders.app_directories.Loader` is in your `TEMPLATE_LOADERS`), but glad you got it sorted! – mfitzp Apr 30 '13 at 13:43