JavaScript Django: return HTML file including script django return html string,django return html file,django return

I am working on a single page application called 'bookMarks' using HTML+CSS+jQuery as the front end and Django as my back end. I created a Django project and put my app.html+app.js+app.css+jquery.js in /static.

My question is: I would like my view to return the app.html as it should be without using Django template. I have tried this:

#app/views.py
from django.shortcuts import render_to_response, HttpResponse
import urllib
def index(request):
    index = urllib.urlopen('static/app.html').read()
    return HttpResponse(index)

#static/app.html
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <title>My Bookmarks</title>
    <link type="text/css" rel="stylesheet" target='_blank' href="app.css">
    <script src="jquery.js"></script>
    <script type='text/javascript' src="app.js">
    jQuery.noConflict();
    </script>
</head>
<body>
    <div id="title">
        Easy-Save Bookmarks
    </div>
    <div class="left">
        <h3 class="tag">News</h3>
            <div>
                <p> A book mark here!</p>
            </div>
        <h3 class="tag">Reading</h3>
            <div>
                <p> A book mark here!</p>
            </div>
            <div id="newTag"></div>
            <div>
                <form name="addTagForm">
                    <input type="text" name="newTag">
                    <input id="addTag" type="button" value="Add a new tag">
                </form>
            </div>
    </div>
    <div class="right">
    </div> 
</body>
</html>

But it seems that all JS and CSS effects are ignored.

Could someone help me to fix this?

Answer:1

I have a button and an image and want them to change color onmouseover. The button changes color fine: <script> function secondColor(x) { x.style.color="#000000"; } function firstColor(x) { x....

I have a button and an image and want them to change color onmouseover. The button changes color fine: <script> function secondColor(x) { x.style.color="#000000"; } function firstColor(x) { x....

  1. javascript make image clickable
  2. javascript make image appear on click
  3. javascript make image visible
  4. javascript make image transparent
  5. javascript make image bigger on hover
  6. javascript make image black and white
  7. javascript make image move across screen
  8. javascript make image background transparent
  9. javascript make image smaller
  10. javascript make image fit screen
  11. javascript make image bigger on click
  12. javascript make image invisible
  13. javascript make image grayscale
  14. javascript make image a button
  15. javascript make image
  16. javascript make image bounce around screen
  17. javascript make image disappear
  18. javascript make image full screen
  19. javascript make image spin
  20. javascript make image draggable

Using the bootstrap-tour plug-in (http://bootstraptour.com/), I want to disable or hide the default 'End Tour' button on each step except for the very last step. I tried modifying the step template ...

Using the bootstrap-tour plug-in (http://bootstraptour.com/), I want to disable or hide the default 'End Tour' button on each step except for the very last step. I tried modifying the step template ...

My original (working) code looks like: jQuery().ready(function ($) { $('[id="errorMessages"]').ajaxStart(function () { $(this).html(""); }); $('[id="errorMessages"]').ajaxError(...

My original (working) code looks like: jQuery().ready(function ($) { $('[id="errorMessages"]').ajaxStart(function () { $(this).html(""); }); $('[id="errorMessages"]').ajaxError(...

I am storing html data in my database from the output of a WYSIWYG editor. The html also stores the html for some directives. One of them being the ui-bootstrap tooltip: <span tooltip-placement="...

I am storing html data in my database from the output of a WYSIWYG editor. The html also stores the html for some directives. One of them being the ui-bootstrap tooltip: <span tooltip-placement="...

  1. rendering html angular
  2. render html angular 6
  3. render html angular 7
  4. render html angular 4
  5. render html angular 2
  6. angularjs render html
  7. render html angular 5
  8. render html string angular
  9. render html string angular 6
  10. render html text angular
  11. render raw html angular
  12. render html in angular variable
  13. render html in angular 8
  14. re render html angular
  15. dynamically render html angular
  16. render html in angular component