Django Framework

Django is a highly popular, full-stack, open-sourced framework of Python that includes all Python features by default. This high-level framework handles much of the intricacies of web development in a built-in manner, and allows developers to focus on the logic of their apps. Django also offers inherent support for commonly-used database systems and ORM support to map objects to tables, which facilitates easy data migration.

This example illustrates the steps to build a simple Python app with the Django framework. This application will then be bundled and associated with an AppSail service, and deployed to the console.

  1. Create a new folder in your local system for the Django app.

  2. Navigate to the directory from your terminal and execute the following command to install Django:

    
copy
python3 -m pip install django -t .
  1. Create a Django project by executing the following command.
    
copy
python3 -m django startproject mysite
Note: You will need to configure your AppSail domain in ALLOWED_HOSTS as mentioned in this help section.
  1. You can now initialize an AppSail service in the same directory from the CLI or add it in an existing project directory. The app’s source must be your application’s directory. Provide the following value while initializing the app service:

    Stack: Python_3_9

  2. Ensure all the Python application files along with the django modules are present in the build directory you specify during initialization. Catalyst will automatically ZIP your app files during deployment to the remote console.

  3. Deploy the app service to the console.

  4. You can then configure the startup command given below from the console:

    
copy
sh -c 'python3 -u mysite/manage.py runserver 0.0.0.0:${X_ZOHO_CATALYST_LISTEN_PORT}'

You can also configure this in the app-config.json file before deploying.


Access the deployed app service from its endpoint URL.

Last Updated 2023-12-14 16:25:23 +0530 +0530

ON THIS PAGE