Reputation: 422
I'm sending a message with HTML via Python. Now, I'd like to style it, I've tried to write the style code into the html but there are problems because curling braces {}. Can I link the css file in Python?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Lato:400,900i&display=swap" rel="stylesheet">
<link rel='stylesheet' href="css/message_style.css"> #I've a static folder
</head>
<body>
Upvotes: 0
Views: 6251
Reputation: 10520
You can do both inline stylings and also insert your CSS files into your HTML from a static folder like this:
{% load static from staticfiles %} or {% load static %}
<link rel='stylesheet' href="{% static 'css/message_style.css' %}">
Note: You should load static directory before using {% static 'relative address to the file' %}
, and both {% load static from staticfiles %}
or {% load static %}
will do the same for you but the first one is more explicit.
EDIT: If you want to send out emails and make an email template you should use inline styles and use tables, to achieve that you can check this link for more information.
Upvotes: 1