Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
.env 'PAYPAL_API_USERNAME' is not defined

I am trying to set my sensitive data into my .env file.

I did some researched and created this file successfully.

https://ultimatedjango.com/learn-django/lessons/handling-sensitive-keys/

https://django-environ.readthedocs.io/en/latest/

I am able to set my secret key and database settings and access it through my settings.py, everything works fine. Like for example -

     env.db()SECRET_KEY = os.environ["SECRET_KEY"]

     DATABASES = {
     'default': env.db(), # Raises ImproperlyConfigured exception if                 DATABASE_URL not in os.environ
      }

And database details prints in my python shell. And django-oscar runs with no problem.

Now, I am trying to set my Paypal details within the same .env file, but seems to be having problems. in my .env file I have the setting as -

   #PAYPAL SETTINGS



  export PAYPAL_MODE=sandbox   # sandbox or live 

  export PAYPAL_CLIENT_ID=my_paypal_client_id 

 export PAYPAL_CLIENT_SECRET=my_payal_secret 



 #PAYPAL SETTINGS 

 export PAYPAL_API_USERNAME=mypaypalusername.com 

 export PAYPAL_API_PASSWORD=my_password 

 export PAYPAL_API_SIGNATURE=my_signature

In my settings.py I am trying to make a reference to it so my application can access it -

  #PAYPAL SETTINGS 
  PAYPAL_API_USERNAME = os.environ["PAYPAL_API_USERNAME"] 
  PAYPAL_API_PASSWORD = os.environ[PAYPAL_API_PASSWORD] 
  PAYPAL_API_SIGNATURE = os.environ[PAYPAL_API_SIGNATURE] 

  import paypalrestsdk 

  PAYPAL_MODE=os.environ['PAYPAL_MODE'] 
  PAYPAL_CLIENT_ID=os.environ['PAYPAL_CLIENT_ID'] 
  PAYPAL_CLIENT_SECRET=os.environ['PAYPAL_CLIENT_SECRET']

I get errors when running server -

 PAYPAL_API_USERNAME=os.environ[PAYPAL_API_USERNAME]



  NameError: name 'PAYPAL_API_USERNAME' is not defined

I have done some research but not got an answer specifically for this problem. Please, can somebody kindly point me to the right direction?

Thank you.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

use

os.environ.get('PAYPAL_API_USERNAME')
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!