![]() ![]() Go into your app directory and activate your Python environment: cd ~/apps/myapp SSH into your app's server as the app's shell user.Įdit your project's settings.py to set the following variables: STATIC_ROOT = '/home/username/apps/mystatic' ![]() The remainder of these steps will refer to the application as "mystatic".Įdit your site to add a site route serving the mystatic application on the URI path /static. Nginx serves static content more efficiently than uWSGI, so your static content will load faster for your visitors.Ĭreate a "Nginx Static Only" application and make a note of the application name.Since your backend uWSGI server isn't servicing requests for static media, it's able to service dynamic requests more efficiently.This configuration improves the overall performance of your application in a couple of ways: This procedure will configure your site to serve your Django applications static assets directly from Opalstack's frontend Nginx server via a separate static application. Serving static content for your Django project ¶ SSH into your Django application's shell user account and run the following commands to install the PostgreSQL dependencies for Python (substituting myapp with your Django application name): source ~/apps/myapp/env/bin/activateĬonfigure DATABASES in your project's settings.py as follows: DATABASES = /newsite/newsite/wsgi.py To use a PostgreSQL database with your Django project:Ĭreate a new PostgreSQL database and user and make a note of the following: Using Databases with Django ¶ PostgreSQL ¶ See Installing Python dependencies for your project in our uWSGI documentation. Installing Python dependencies for your Django project ¶ Run the following commands to restart your Django instance: /home/username/apps/appname/stop Please take the following steps before you begin to use your Django installation:Ĭonnect your Django application to a site in the dashboard.Įdit the app's myproject/myproject/settings.py to set ALLOWED_HOSTS to include your site's domains.Įxample: ALLOWED_HOSTS = ['', ' uwsgi.ini: the uWSGI configuration file for your Django application.myproject: a directory containing a demo Django project.tmp: a directory containing temporary files used by your application.env: a directory containing the Python 3 environment used by your application.start and stop: scripts to control the operation of your application.When the installation is complete, the following files and directories will be present in the application directory: To install a Django application follow our general instructions for adding applications and select "Django" as the application type in step 5. Opalstack provides a simple installer for Django with Python 3.10 served by uWSGI. Django is a popular web application framework built with Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |