S
S
shudry_toster2017-09-27 21:58:29
Django
shudry_toster, 2017-09-27 21:58:29

Django: 'Settings' object has no attribute 'NEXMO_USERNAME'?

INSTALLED_APPS = [
    ...
    'dbmail',
]
DB_MAILER_SMS_PROVIDER = 'dbmail.providers.nexmo.sms'
NEXMO_USERNAME = 'My Api Key'
NEXMO_PASSWORD = 'My Api Password'
NEXMO_FROM = 'example.com'
NEXMO_LANG = 'en-us'

I call the send SMS function:
from dbmail import send_db_sms
send_db_sms('sms-test', recipient)

An error pops up in the logs and SMS is not sent:
Traceback (most recent call last):
File "/home/my-user/project/virtual/local/lib/python2.7/site-packages/dbmail/backends/mail.py", line 286, in send
self._send()
File "/home/my-user/project/virtual/local/lib/python2.7/site-packages/dbmail/backends/sms.py", line 36, in _send
phone, message, sms_from=self._from_email, **self._kwargs)
File "/home/my-user/project/virtual/local/lib/python2.7/site-packages/dbmail/providers/nexmo/sms.py", line 22, in send
'api_key': settings.NEXMO_USERNAME,
File "/home/my-user/project/virtual/local/lib/python2.7/site-packages/django/conf/__init__.py", line 57, in __getattr__
val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'NEXMO_USERNAME'

In Shell:
>>>from django.conf import settings
>>>settings.NEXMO_USERNAME
>>>'My Api Key'

And how can this be understood?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom Innokentiev, 2017-09-28
@shudry_toster

Most likely, you have several settings: default, local, stage, staging, productionand stuff like that. Try to explicitly specify the desired settings file when starting the server

python manage.py runserver --settings mysettingspackage.mysettingsmodule

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question