Django With Wasabi

Prev Next

Django is validated to use with Wasabi S3 storage. It is a web framework designed to create websites using Python.

Designing a Basic Web Framework in Django

  1. Start by installing Django and setting up a project.

    $ pip install django
  2. To confirm your installation was successful, run the following command, and you should see available sub-commands.

    $ django-admin
    
                    Type 'django-admin help ' for help on a specific subcommand.
    
                    Available subcommands:
    
                    [django]
                        check
                        compilemessages
                        createcachetable
                        dbshell
                        diffsettings
                        dumpdata
                        flush
                        inspectdb
                        loaddata
                        makemessages
                        makemigrations
                        migrate
                        runserver
                        sendtestemail
                        shell
                        showmigrations
                        sqlflush
                        sqlmigrate
                        sqlsequencereset
                        squashmigrations
                        startapp
                        startproject
                        test
                        testserver
  3. To create a new project, you can use the startproject command.

    $ django-admin startproject 
  4. This will automatically create the basic Django framework. Navigate inside your project where the manage.py file has been created. Use the following command to run the server.

    $ python manage.py runserver
  5. You will see the output below, which indicates your server is now running on port 8000.

  6. If you go to port 8000 on your web browser, you will see the Django server running on your system.

Enabling Your Django Project to Communicate With Wasabi S3 Storage

  1. Install django-storages.

    $ pip install django-storages
  2. Install boto3 library.

    $ pip install boto3
  3. Add storages to your  INSTALLED_APPS  inside the settings.py module, as shown below:

  4. Configure the settings.py module to support the S3 backend.

The following is an example of a configuration that would allow your Django web application to communicate with Wasabi. Be sure to use your own details.

AWS_ACCESS_KEY_ID = 'Wasabi-Access-Key'
        AWS_SECRET_ACCESS_KEY = 'Wasabi-Secret-Key'
        AWS_STORAGE_BUCKET_NAME = 'Wasabi-Bucket-Name'
        AWS_S3_ENDPOINT_URL = 'https://s3.us-east-2.wasabisys.com'

This code example shows the use of Wasabi's us-east-2 storage region. You can use any other appropriate Wasabi service URL.

You can design and let Django put your static assets in your Wasabi bucket so that you can connect it directly to your deployment script.

$ python manage.py collectstatic

You can see that those files are now in the Wasabi bucket and can be interacted with your framework from there directly.

Note that the example above is only a sample to illustrate the settings needed to communicate with Wasabi Hot Cloud Storage. Wasabi expects users to build and develop their own Django framework application as per their requirement(s) and use the above settings to configure the S3 storage library.