i have a question.
Im working on a Project and i finished the Logic Part. So this was my first Project with Django and Web in generell. And my .html files are really really bad! So, now i want to change this. Work with a new Template and rework this a bit.
The first "base.html" was from W3Schools and now i want to use a bootstrap Theme. The Question is, how can i import the Files?
So i know that i have to put css,js Files into my static Folder and then import them into my base.html.
The Thing now is, that i have much Folders and Files. I have a css, img, js, scss and vendor Folder and some Files like package.json, gulpfile.js and stuff like that.
In these Folders are files like .css or .min.css, .js and .min.js, much scss Files and in the Vendor File are even more Folders with Files!
So the question now is, how can i import this good? That i dont destroy anything, which File should be in css, js and ?scss? dont know if i need a file for this in django! And how can i import them correct? Maybe anyone has an Example?
Would be really nice if someone can help me a bit with this!
Thanks!
For now, don't use any of those downloaded files, and use the hosted versions - it will be simpler. From Bootstrap's introduction:
Copy-paste the stylesheet <link> into your <head> before all other stylesheets to load our CSS.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
And:
Many of our components require the use of JavaScript to function. Specifically, they require jQuery, Popper.js, and our own JavaScript plugins. Place the following s near the end of your pages, right before the closing tag, to enable them. jQuery must come first, then Popper.js, and then our JavaScript plugins.
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
Note, you might not need the popper.min.js - read the instructions on that page.
Once you get that working, you could replace them with local files if you want. In the downloaded Bootstrap directory, they'll be in dist/css/ and dist/js/. You'll also need to download jQuery (or keep linking to it remotely).
Related
Set relative path folder in Svelte build
When I build my svelte app with the command npm run build, it's export the links like this:
<script type="module" crossorigin src="/assets/index-54c7d896.js"></script>
<link rel="stylesheet" href="/assets/index-d3d038e5.css">
More accurately it call to the root localhost/assets...
// src="/assets/index-54c7d896.js"
// href="/assets/index-d3d038e5.css"
And I get this:
Error from the navigator
From here:
where I want use the svelte app
And easy solution is using a relative path to:
// from "/assets/..." to "./assets/..."
src="./assets/index-54c7d896.js"
href="./assets/index-d3d038e5.css"
But the thing is I can't do that inside javascript and css files.
These still use an absolute path.
So this is what happens:
when a css file call other files using absolute path
I mean I could dig into a compiled file but it's not efficient
I tried change manually the paths on each file but it's a lot of work each time than I have to compile.
I'm using a hosting with php so I tried using .htaccess but it's hard too.
I am expecting this to be configurable from svelte.
I really love ❤️ this framework, thanks in advance for your help.
How do i add an external css/js to my html template when working with django
i've tried some previously asked questions reply but seem like they're outdated and below is one of the procedure i followed
# after making sure the installed app has contrib.static then i make a file called static/my_apps/my.css
{%loadstatic%}
<link rel='stylesheet' href="{%static 'my_apps/my.css' %}">
# i also tried {%loadstaticfile%} but none work
When creating your project you have a specific django folder hierarchy and where you create your templates folder, at the same place create the folder with the name static and add all your static files (js/css/images) in it. and then while accessing use the static tag to access it in templates. {%static 'path/to/your/static/files'%} this path django engine takes from the static folder.
I'm very interested in using CLJS and Untangled to make a dynamic web app. I have some very basic questions, though. My first question is: I see that like in other frameworks, there is a base index.html that has a .js file reference and the <div id="app"></div> is tied to the javascript file.
So in the Untangled Template project from github, I have my Figwheel server running and I wanted to do some tinkering on the dev-index side.
<body>
<div class="container-fluid" id="app"><div>Now loading super sweet app</div></div>
<script src="js/untangled_template.js" type="text/javascript"></script>
</body>
However, there's no file called untangled_template.js and I'm wondering what would be the bare minimum scaffolding for such a .js file.
Having used Clojure, but not really broken into Clojurescript yet, I'm curious how this .js file comes to be (since presumably it's first written in cljs)
Thanks many
Disclaimer: I've never used Untangled.
This line of the Untangled template's project.clj is probably what you're looking for. Note how in the :cljsbuild section of this file, there are several builds listed - when you run lein figwheel, the dev profile is used, and whenever you make changes to your cljs code, Figwheel compiles your cljs (note the :source-paths part of this build map) and puts the generated JS in resources/public/js/untangled_template.js.
You say you're not seeing an untangled_template.js file - do you mean that you don't see a file with that name in the root directory of your Leiningen project, or do you mean that when you load your index.html in a Web browser it complains that it can't find /js/untangled_template.js?
My current HTML page has run into 1000 lines of code. I wanted to make it more manageable.
So the kind of solution I'm looking for is -
<script type="text/x-handlebars" data-load-template="detail.html">
And the code should be able to load detail.html from an external source.
How do I do it?
You may choose to use some kind of build tool like grunt that will compile handlebars files to javascript and attach them to you code.
Here is a project that you may find useful: https://github.com/yaymukund/grunt-ember-handlebars
I'm trying to build Dojo 1.6.1.
I ran C:\somepath\dojo-release-1.6.1-src\dojo-release-1.6.1-src\util\buildscripts>build.bat action=release htmlFiles="C:\path\test.jsp"
Test.jsp contained a few js files. One of which contained all the require statements.
Now I have a release\dojo folder, but if I put these contents into my original source location, it will break my test.jsp's <script> tags.
I found some documentation of the build process: http://dojotoolkit.org/documentation/tutorials/1.6/build/
I could not find documentation on how to DEPLOY the build. Is the deploy simply a copy paste but the problem was that my build didn't work properly?
A Dojo custom build is intended to serve as a drop-in replacement for a standard full Dojo distribution as you would include via:
<script type='text/javascript' src='/path/to/dojo/dojo/dojo.js'></script>
Typically deployment is simply changing that to:
<script type='text/javascript' src='/path/to/your-custom-dojo/dojo/dojo.js'></script>
If your test.jsp file does things like dojo.require() with inline <script> tags, they should continue working correctly.