munacips
munacips

Reputation: 1

I am working on a djnago project and I am using django_bootstrap_icons, I have installed it using pip and done everything but they aren't showing

settings.py

INSTALLED_APPS = [
    ...
    'myapp',
    'django_bootstrap_icons',
]
...

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

MEDIA_ROOT = os.path.join(BASE_DIR,'static,'media')
STATIC_ROOT = os.path.join(BASE_DIR,'static','static_root')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'static','static_files')
)

home.html

...
{% load static %}
<link rel="stylesheet" href="{% static 'bootstrap_icons/css/bootstrap_icons.css' %}">
...

{% load bootstrap_icons %}
{% bs_icons 'alarm' %}

Is there something I've done wrong. I installed the django bootstrap icons using pip and I even did the

py manage.py collectstatic

And still it's saying

Icon does not exist

However the icons appear if I connect to the Internet but since I've installed the django bootstrap icons, I want the icons to appear even when I'm offline because I don't have Internet access everytime...

Upvotes: 0

Views: 2260

Answers (3)

you probably found out, you have a spelling. You need to write:

    {% bs_icon 'alarm' %}

Upvotes: 0

Dixan
Dixan

Reputation: 317

From the docs...

https://pypi.org/project/django-bootstrap-icons/

Configuration You can specify the source from which the icons are loaded:

BS_ICONS_BASE_URL = 'https://cdn.jsdelivr.net/npm/[email protected]/'

BS_ICONS_BASE_URL defaults to the latest boostrap-icons CDN that was available when releasing this package. Change the URL to use an older or newer one.

So you need to be connected to the internet in order to get the icons from the CDN(cdn.jsdelivr.net).

To add custom icons to your app you need to set the path where these can be found. The default setting is custom-icons, so you would add your icons to /your-app/static/custom-icons/.

So to get them when not connected to the internet, download the icons to your assets folder and then use BS_ICONS_CUSTOM_PATH = '/your/asets/path/custom-icons'

BS_ICONS_CUSTOM_PATH = 'custom-icons'

Upvotes: 1

ttt
ttt

Reputation: 300

You have a wrong declaration. Should be {% load static %}.

Upvotes: 0

Related Questions