Get 2024 Templates Mega Bundle!19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets
Get for 99$

Metronic-Django deploy


What is the correct way for deploying a Metronic-Django web application in a apache Debian server using mod-wsgi


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (8)


Hi Yasniel Alejandro

Try update STATICFILES_DIRS in your settings: In your _keenthemes/settings.py, add the directory containing your SVG files to STATICFILES_DIRS. For example

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
os.path.join(BASE_DIR, "assets", "media", "icons"),
]


If you're in a production environment, try to run python manage.py collectstatic to collect all static files into the directory specified by the STATIC_ROOT setting.

https://docs.djangoproject.com/en/5.0/ref/contrib/staticfiles/

Thank you



Hi

Sorry for the delay. Check that the application has the necessary permissions to read the SVG files in server. Look at the browser's console for any errors related to loading SVG icons.

To diagnose further, you might want to re-enable the SVG loading code and add some debugging to see where it might be failing. For example:


def getSvgIcon(path, classNames = "svg-icon", folder = "media/icons/"):
try:
svg_path = "." + KTTheme.asset(folder + path)
with open(svg_path, "r") as svg_file:
svg = svg_file.read()
output = "<span class="{}">{}</span>".format(classNames, svg)
except Exception as e:
output = "<span class="{}">Error: {}</span>".format(classNames, str(e))
return output

This should help you identify if there's a specific issue with reading the SVG files.



Hi, thank's for yor concern, i'm getting this error:

Error: [Errno 2] No existe el fichero o el directorio: './assets/media/icons/duotune/general/gen021.svg'

The archive exist and has access permissions



Hi Faizal

I've modify the method getSvgIcon of KTTheme class for testing and the project loads fine without svg icons

def getSvgIcon(path, classNames = 'svg-icon', folder = 'media/icons/'):
# Reference to current folder
#svg = open('.' + KTTheme.asset(folder + path)).read()
#output = '<span class="{}">{}</span>'.format(classNames, svg)
output = '<span class=""></span>'
return output

I guess I missed up some dependencies when install the project, any ideas??



Hi Yasniel Alejandro

Check the Import. Ensure that the KTBootstrapDefault class is correctly imported in your theme.py file. Check the function def setLayout

Check for layout path: KT_THEME_LAYOUT_DIR in _keenthemes/settings.py

After making any changes, restart the Apache server to apply the changes

Let me know if you need further assistance!



Hi
I have these configurations in my files:
_keenthemes/settings.py : KT_THEME_LAYOUT_DIR = 'layout'

_keenthemes/libs/theme.py :
from django.conf import settings
from pprint import pprint
import os
from django.templatetags.static import static
from importlib import import_module, util
import json
from django.core.cache import cache

def setLayout(view, context = {}):
KTTheme.htmlAttributes = {}
KTTheme.htmlClasses = {}

layout = os.path.splitext(view)[0]
layout = layout.split('/')[0]

# Get module path
module = '_templates.{}._bootstrap.{}'.format(settings.KT_THEME_LAYOUT_DIR.replace('/', '.'), layout)

# Check if the bootstrap file is exist
if not util.find_spec(module) == None:
# Auto import and init the default bootstrap.py file from the theme
KTBootstrap = KTTheme.importClass(module, 'KTBootstrap{}'.format(layout.title().replace('-', '')))
KTBootstrap.init(context)
else:
module = '_templates.{}._bootstrap.default'.format(settings.KT_THEME_LAYOUT_DIR.replace('/', '.'))
KTBootstrap = KTTheme.importClass(module, 'KTBootstrapDefault')
KTBootstrap.init(context)

return '{}/{}'.format(settings.KT_THEME_LAYOUT_DIR, view)

_keenthemes/templatetags/theme.py:
from django.utils.safestring import mark_safe
from django import template
from _keenthemes.libs.theme import KTTheme
from django.conf import settings
from pprint import pprint



Hi Yasniel Alejandro

You may refer to this docs about deployment Django project using Apache with wsgi

https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/modwsgi/

Thank you



I've done all the hints described in the docs, but I'm getting these error
in apache log:
[wsgi:error] File "/var/www/.............../starterkit/_keenthemes/libs/theme.py", line 90, in getSvgIcon
[wsgi:error] 'Loading KTBootstrapDefault from _templates.layout._bootstrap.default'

I'm deploying in apache2 (Debian 12)


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(