avocado
avocado

Reputation: 2735

How to reuse website templates (layout/theme) in Python Django?

I'm new to web-dev, but among those simple apps I wrote in Django, there's a simple base_generic.html as the website page template, like this

<!DOCTYPE html>
<html lang="en">
<head>
  {% block title %}<title>Local Library</title>{% endblock %}
</head>
<body>
  {% block sidebar %}<!-- insert default navigation text for every page -->{% endblock %}
  {% block content %}<!-- default content text (typically empty) -->{% endblock %}
</body>
</html>

inside which we have a few blocks, so that we could extends from there to add new page content.

This html template is really simple and poor-looking, and I need some good-looking page templates, so I wonder

1) could it be possible to download website page templates of, say WordPress (they have many beautiful ones), and use in Django?

2) or what's the typical we to resolve my issue in Django world?

Upvotes: 0

Views: 576

Answers (1)

pomo_mondreganto
pomo_mondreganto

Reputation: 2074

Basically, the WordPress (or any other) templates consist of several parts. There's an html carcass, CSS styles applied to elements and some JavaScript logic.

To use page templates, you need to find and download the whole pack: the html page itself and CSS and JS it's using and put CSS and JS to static files (see this article about serving states files in Django).

Then you just serve your html templates, which include static files from your static folder.

Upvotes: 1

Related Questions