Skip to main content

A Python script that converts HTML Files / Templates to Django compatible HTML Templates.

Project description


A Python script that converts HTML Files / Templates to Django compatible HTML Templates.

Usage Info

username@hostname $ ./ -h
usage: [-h] [-d [BASE_DIRECTORY]] [-a [APP_NAME]] [f [f ...]]

Converts specified html files or all html files to django format within a
specified directory.

positional arguments:
  f                    provide file names to convert

optional arguments:
  -h, --help           show this help message and exit
  -d [BASE_DIRECTORY]  Provide base directory
  -a [APP_NAME]        provide django app name


Converts all the HTML files specified in the files (' f ') argument into Django templates, replacing the contents of 'src', 'href' and 'url' tags with their Django compatible static conterparts with their Django App name prefixed.

For Example:

To process a set of HTML files, copy the script to the directory containing these HTML files, and run the following command, (Here 'blog' refers to the App name for which we are processing these files)

$ ./ -a blog

This command will replace all local files referenced in 'src', 'href' and 'url' tags in the following way :

Original :

    <img class="mySlides" src="res/landreg/1.jpg" style="width:100%">
    <li><a href="register.html">Register</a></li>

After script execution :

   <img class="mySlides" src=" {% static 'blog/res/landreg/1.jpg' %} " style="width:100%">
   <li><a href=" {% static 'blog/register.html' %} ">Register</a></li>

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for djangify, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size djangify-1.0.0-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size djangify-1.0.0.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page