/DjangoHtmlFiller

This code is for those who are tired of inserting {% static ' ' %} in every href,src links in html files while creating a Django project.

Primary LanguagePythonMIT LicenseMIT

DjangoHtmlFiller

This code is for those who are tired of inserting {% static ' ' %} in every href,src links in html files while creating a Django project 💁‍♂️

From this :

Normal Html

To this :

Formatted for Django

Purpose:

  • The Main puspose of this code is to save hours of work by automatically scanning through & updating all the html files in the given folder.
  • It will store all the updated files in a seperate folder in the same directory without harming the original files.
    • You can examine & finalize all the changes and then cut+paste those files in place of original files later on.
    • You won't lose any of your files.
  • This code is properly tested & works 100% of the time. ✔️

Requirements:

  • Python 3

How To Use:

1. Through Github:

Steps:

  1. Clone this repository anywhere in your pc. (No need to clone in your Django project folder!)

  2. Now do cd (Cloned Directory path)/DjangoHtmlFiller/OsScrawler.py and then run OsScrawler.py program.

    Run Code

  3. Now the program will ask for the folder in which all your html/htm files are stored. In this example all of Django Project's html files are stored in templates folder.

    Assets Folder

  • You can give the program full path of that folder (all the html files within that folder will be scanned) or you can directly give the path of the html file you want to scan & update (only that file will be scanned).

  • In this case I am giving path of the templates folder in which all of the html files are stored.

    Give Full Path

  • The program will scan through given html file(s) & will save converted outputs in Formatter_Generated_Files folder in the same directory.

    program Execution

    Run Code

  • Now just replace this files in place of the original files & you are Done! 👍 😄

You can run this program multiple times for the same folder & it won't affect the already converted files.

2. Using pip:

Steps:

  1. Type the following command in your cmd/anaconda terminal,

pip install DjangoHtmlFiller

  1. Then open default python environment by typing python int your terminal.

  2. Once your python environment has started import the module by doing,

from DjangoHtmlFiller import OsScrawler as dhf

  1. Then the last step is to invoke the function,

dhf.DjangoBot()

The execution process is same as Step 3 of Through Github

And you are done!!

Warning:

  • You CAN'T have more than one href/src links in the same line (super rare case). In this case the code will only formate left most link & you will have to manually formate the other one.

If you have any query regarding this programe you can drop a message at jayshukla0034@gmail.com or at Instagram or Linkedin.

Enjoy! 😄