Integrate CDN resource with Django CMS
Before you take any steps please back up your files and database. The plugin works only with default CMS pattern. If you manually changed CMS patterns, the plugin might not help you.
First, create a CDN resource within the Gcore Customer Portal.
Configure your urls.py file to point the static files to the appropriate static folder (i.e same directory as your media folder)
Before:
After:
Modify the settings.py
file to point your Django application to the CDN.
Find:
Replace CNAME with the CNAME that you specified in the Gcore Customer Portal.
Ensure that your CNAME record has been configured in a proper way before using it for integration
Now any files within the static or media folders should be delivered via the CDN. However, there are still some static files that Django uses to run the CMS. In order to complete the integration, these files should be removed to your STATIC_ROOT
folder, defined in the settings.py file. In order to copy these static files, first, ensure you are running in a virtual environment from the Django root directory
Once this is complete, navigate to your app directory, where the manage.py file is stored, and run the following command:
$ python manage.py collectstatic
Any external static files will now be pulled into your STATIC_ROOT
folder which will subsequently be delivered via the CDN.
Use the STATIC_URL
within your template files in order to reference your files from the static folder, for example:
Integration has been completed! We highly recommend you to check the HTML code of your web page to ensure that URLs have been rewritten properly from your original ones to CNAME from the Gcore Customer Portal.
To do that press F12 or open Developers Tools in your browser, choose the Network tab and refresh the page. All static files should have your CNAME in URLs.