LPgenerator / django-db-mailer

Django module to easily send emails/sms/tts/push using django templates stored on database and managed through the Django Admin
https://github.com/LPgenerator/django-db-mailer
GNU General Public License v2.0
256 stars 80 forks source link

SyntaxError: non-keyword arg after keyword arg #5

Closed bijenkins closed 9 years ago

bijenkins commented 9 years ago

send_db_mail( ... # slug - which defined on db template ... slug='welcome', ... ... # recipient can be list, or str separated with comma or simple string ... # 'user1@example.com' or 'user1@example.com, user2@example.com' or ... # ['user1@example.com', 'user2@example.com'] or string Mail group slug ... recipient='test@mysite.com', ... ... # All *args params will be accessible on template context ... { ... 'username': request.user.username, ... 'full_name': request.user.get_full_name(), ... 'signup_date': request.user.date_joined ... }, ... ...
... ) File "", line 11 SyntaxError: non-keyword arg after keyword arg

This happens no matter which way, I try to add *args to be pulled into the template context. I tryed data={"test":"This is a test"} with the same result.

Line 11: ... # All args params will be accessible on template context ... { < *** ... 'username': request.user.username,

Python 2.7.9 Django 1.7.4

bijenkins commented 9 years ago

I researched on the internet this issue further, and see that it only occurs when trying to actually add variable data for the template. So I tried ever order imaginable, and a direct copy and paste of your examples has not worked for me. Please take a look when available.

send_db_mail({'snmp_location':'This is a test'}, slug='welcome', recipient='test@mysite.com', use_celery=False) Traceback (most recent call last): File "", line 1, in TypeError: send_db_mail() got multiple values for keyword argument 'slug'

send_db_mail (slug='welcome', {'snmp_location':'This is a test'}, recipient='test@mysite.com', use_celery=False)
File "", line 1 SyntaxError: non-keyword arg after keyword arg

send_db_mail (slug='welcome', {'snmp_location':'This is a test'}, recipient='test@mysite.com')
File "", line 1 SyntaxError: non-keyword arg after keyword arg

send_db_mail (slug='welcome', recipient='test@mysite.com', {'snmp_location':'This is a test'}) File "", line 1 SyntaxError: non-keyword arg after keyword arg

send_db_mail (slug='welcome', recipient='test@mysite.com', {'snmp_location':'This is a test'}, use_celery=False) File "", line 1 SyntaxError: non-keyword arg after keyword arg

gotlium commented 9 years ago

slug='welcome' , recipient='test@mysite.com' - because this is a not named arguments. Look to my examples on README. On basic example which you are using, I showed all possible keywords, slug and recipient can not be used as keyword.

def send_db_mail(slug, recipient, *args, **kwargs):
     ...