Install¶
Install package in your environment :
pip install django-icomoon
For development usage see Install for development.
Configuration¶
Add it to your installed Django apps in settings :
INSTALLED_APPS = (
...
"icomoon",
)
Then load default application settings in your settings file:
from icomoon.settings import *
Then mount applications URLs:
urlpatterns = [
...
path("", include("icomoon.urls")),
]
There is no database migrations to apply.
Webfonts and manifests¶
Now you must define at least one webfont in your project settings like this:
ICOMOON_MANIFEST_FILEPATH = {
"Default": {
"fontdir_path": "/home/work/myproject/static/fonts/default",
"csspart_path": "/home/work/myproject/static/css/icomoon_icons.scss"
},
}
Each website entry is a dict containing the following values:
- fontdir_path
(Required) Absolute path to the webfont directory. It will be created with Manifest file and font files on each deploy.
- csspart_path
(Optional) Absolute path where will be written the css part containing webfont icons.
Templates¶
This is at your responsability to load the webfont and CSS (which enable icons from webfont) into your website templates, this app won’t do it for you.
Note that shipped template gallery in templates/icomoon/ is inherits from
a templates/skeleton.html that you have to create yourself.
Here is an example of a this skeleton template:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block head_title %}Sample site{% endblock %}</title>
{% block head_assets %}{% endblock %}
</head>
<body>
{% spaceless %}
{% block base_content %}{% endblock %}
{% endspaceless %}
</body>
</html>
The most important thing to retain is the template block base_content where
the app template will insert its content.
Settings¶
Default application settings¶
These are the default settings you can override in your own project settings right after the line which load the default app settings.
- icomoon.settings.ICOMOON_WEBFONTS = {}¶
ICOMOON_WEBFONTS = { "Default": { # Where the font files belong and where they will be deployed "fontdir_path": "/home/foo/bar/static/fonts", # Where the css part with all icon selectors will be written "csspart_path": "/home/foo/bar/static/css/icomoon_icons.scss", }, }
- Type:
Define available webfonts
- icomoon.settings.ICOMOON_PRIVATE = True¶
Private mode require to be logged to reach the gallery, use False to grant access to anonymous users
- icomoon.settings.ICOMOON_MANIFEST_FILENAME = 'selection.json'¶
Manifest filename, this is a Icomoon standard so you should not change it
- icomoon.settings.ICOMOON_CSS_TEMPLATE = 'icomoon/icon_map.css'¶
Path to the CSS template that will contain icon map, this relative to templates directory
Use this instead to create a Sass file with icon exposed as variables:
ICOMOON_CSS_TEMPLATE = "icomoon/icon_map.scss"
- icomoon.settings.ICOMOON_ARCHIVE_REQUIREMENT = {'extensions': ['ttf', 'svg', 'eot', 'woff', 'woff2'], 'font_dir': 'fonts'}¶
Structure and file requirements for the Icomoon webfont archive.
Also paths are relative within ZIP archive.