How can I correctly use djangify with the django framework?

Viewed 508

I am testing djangify but running into issues:

djangify -d main/templates/main
INFO:Directory : main/templates/main
INFO:app_name  : None
INFO:Succeeded.. Generated Modified_Files/index.html in the directory passed.
INFO:Directory : main/templates/main
INFO:app_name  : None
INFO:Succeeded.. Generated Modified_Files/index.html in the directory passed.

The CSS and images are not showing (I'm getting HTTP 404 errors):

enter image description here

> StatReloader Performing system checks...
> 
> System check identified no issues (0 silenced). May 25, 2020 -
> 19:20:00 Django version 3.0.6, using settings 'MyProject.settings'
> Starting development server at http://127.0.0.1:8000/ Quit the server
> with CTRL-BREAK. [25/May/2020 19:20:03] "GET / HTTP/1.1" 200 43240 Not
> Found: /assets/vendor/bootstrap/css/bootstrap.min.css [25/May/2020
> 19:20:03] "GET /assets/vendor/bootstrap/css/bootstrap.min.css
> HTTP/1.1" 404 2238 Not Found: /assets/vendor/icofont/icofont.min.css
> [25/May/2020 19:20:03] "GET /assets/vendor/icofont/icofont.min.css
> HTTP/1.1" 404 2214 Not Found:
> /assets/vendor/boxicons/css/boxicons.min.css ...

Any clue as to why it's not working?

2 Answers

It appears that Django cannot find your static files (CSS, JavaScript, images, etc.), hence all the 404 errors. Make sure that those directories and files exist (for example, /assets/vendor/bootstrap/css/bootstrap.min.css)and that your system is configured to use static files in accordance with the Django documentation:

https://docs.djangoproject.com/en/3.0/howto/static-files/

To add to the solution here, while creating Djangify, we thought that the choice of using the converted script should be left to the user thus, the modified files are generated inside the folder Modified_Files, you would need to copy-paste those files inside your templates/app_name folder for it to be consistent with the URLs and views.

Also in case, you want to put the static files inside some other folder then you can also specify that folder's name like so: -a <App Name> so that the static files' path is consistent.

Related