This space is available for advertisement. Please contact us if interested.
Advertise with us
django hosting   0   7786
How to add Favicon to Django websites

A favicon, also known as a shortcut icon, website icon, tab icon, URL icon, or bookmark icon, is a small, iconic image that represents your website. Favicons are most often found in the address bar of your web browser, but they can also be used in lists of bookmarks in web browsers and feed aggregators.

Why should we use favicons:

Favicons are like brand logos. Just like how brand logos make it easier to identify the brand quickly, favicons make it easier to identify your website easily. 

In browsing the history section of Google Chrome, the only thing that makes it easier to find the particular link are the colorful little favicons. Take a look at a sample screenshot below:

favicons in django

Favicons not only help in branding but are useful in SEO.

Creating favicon:

You can use any freely available online tool to generate favicon. 

Generally, the size of favicons is 16x16 or 32x32 pixels. The format of the image must be one of PNG (a W3C standard), GIF, or ICO. 

Including Favicon in Django website:

To show favicon on your Django website, you need to put below the line of code in the head section of the HTML code.

<link rel="icon" href="{% static 'app-name/img/favicon.ico' %}" type="image/x-icon">

For the above link to work, we need to follow below steps:

- Create a directory static in your project structure.
- In this directory create another directory with the name same as your app name
- Inside this directory create three directories, js for keeping javascript files, CSS for keeping CSS files and img for keeping images. This is optional. You can keep all three types of files in one directory as well.
- Put the icon in the directory created in the above step. Path to icon file will be: project->app->static->app-name->img->icon.
- In your settings file, define the below variables.

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

- Upload your website on the hosting server and run the below command.

python collectstatic

Since devices differ in resolution, we might have to create different favicons with different resolutions. For further details please refer

django hosting   0   7786

Related Articles:
How to reset Django superuser password
This article explains 3 methods to reset the user password in Django, What command should be used to reset the superuser password from the terminal in Django application, Changing the user password in Django...
Encryption-Decryption in Python Django
How to encrypt and decrypt the content in Django, Encrypting the critical information in Django App, Encrypting username, email and password in Django, Django security...
How to upload an Image file in Django
This article explains the simple steps of uploading and storing an image in Django application, After storing the image, how to use it in Django template or emails, Uploading a file in Django, Storing image in Django model, Uploading and storing the image in Django model, HTML for multipart file upload...
How to upgrade to paid account on PythonAnyWhere
Which is the best server for hosting Django Apps, Best hosting provider for Django Apps, Cheapest Django Hosting, PythonAnyWhere Reviews, Django Hosting,...
DigitalOcean Referral Badge

Get a .COM for just $5.98!

© 2021-2022 Python Circle   Contact   Sponsor   Archive   Sitemap   Partner Sites: PythonSnippets.Dev  99Dev.Tools