Django is a high-level Python Web framework that aids in quick development and clean, realistic design. It reduces the hassle so we can focus on coding the app rather than reinventing the whole wheel.

Let's Get your Django App running with SAWO


Python, pip (package-management system written in Python used to install and manage software packages)
1. The first step to getting started with SAWO API integration into your Django website/application is to install the sawo package as given below:
pip install sawo
2. Next, you have to import createTemplate, getContext, and verifyToken methods from Sawo. The getContext method is used to create sawo dictionary object from data gain from Django Database. The ways to create the template and verify the token are given in subsequent steps.
from sawo import createTemplate, getContext, verifyToken
3. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
4. Once you create your project, you would need to set your project name and hostname. 4.1. For development in a local machine, the hostname should be set to 'localhost'.
If using ''localhost" as hostname is not working for you, try ""
4.2. For the production, the hostname should be set to your domain.
If you are adding your domain do not add 'https://', "http://', 'www' or even trailing backslash.
Example: should be kept as
5. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
6. Getting Started with the Setup in Django
  • First, create a template for SAWO password-less and OTP-less Authentication on your Django website. Use the code given below for the same:
  • Next, you have to send this data required by _sawo.html. The variable names used in _sawo.html template are sawo.auth_key, sawo.identifier and Therefore, to send this data you have to create a JSON.
  • The "to" route should be a post route that can receive posted data.
  • If you are not aware of how data is passed to templates in Django, it is suggested to look into it first.
There are two methods to do this:
context = {
"auth_key": "<api_key>",
"identifier": "email | phone_number_sms"
"to": <route> #the route where you will receive
the payload sent by sdk
context = {
"auth_key": "785ha-hdjsdsd-799-ss345",
"identifier": "email | phone_number_sms"
"to": login
Step 1: To begin, the sawo api_key and an identifier have to be created from the admin dashboard. The following code can be used in the models of your app.
class Config(models.Models):
api_key = models.CharField(max_length=200)
identifier = models.CharField(max_length=200)
choices = [("email","Email"),("phone_number_sms","Phone")]
Step 2: Next, the of the app has to be set up. Use the code given below for the same.
Route should be the receiving end where you can handle post request
from models import Config
from sawo import getContext
def <your_function>(request):
config = Config.objects.order_by('-api_key')[:1]
context = {
"sawo" = getContext(config,<route>) #the route where you will receive
the payload sent by sdk
Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:
Final Render of SAWO Login
Congratulations !! The SAWO API is now ready to be used in your Django application 🤘.

You can also check out SAWO's
​ Django Sample Code and Deployed App.​

It's okay, we get it! You got Stuck!
Feel free to contact us on #ask-for-help on our Discord​