Before you begin the integration process, make sure you have the following:
- API Access Token: To authenticate your Django application with CommandK, you'll need an API access token. If you haven't obtained one yet, refer to this link for instructions on how to acquire it.
Follow these steps to integrate CommandK with your Django application:
If you haven't already created a Django application, you can set up a new project using the Django CLI or any other preferred method. Here, we'll use the Django CLI for demonstration:
Install Django if you haven't already:
pip install Django
Create a new Django project using the following command:
django-admin startproject my_django_app
my_django_appwith your desired project name.
Navigate to the project directory:
Inside your Django application, you can access secrets as environment variables. Open the appropriate file (e.g.,
settings.py) and add the following code snippet to access an environment variable:
import os from dotenv import load_dotenv load_dotenv() SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
This code uses the
dotenv library to load environment variables and sets the Django secret key as an example.
To run your Django application with the CommandK CLI, you can use the following command:
$ cmdk run <application-name> --environment development -- python manage.py runserver
<application-name> with the actual name of your Django application. This command will execute your Django application, running the development server.
By following these instructions, you can seamlessly integrate the CommandK CLI with your Django application, making it easy to manage secrets and run your application securely.
Updated about 2 months ago