Django: return HTML file including script

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" 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?

-------------Problems Reply------------

Finally I found that's because I didn't include my js+css files in the absolute way.

Now when I put my HTML+JS+CSS files in my_app/static/, and include absolute The view will return my html correctly.

Category:javascript Views:1 Time:2018-07-09

Related post

  • How can I check if a html document includes script tags that are not empty using a regular expression 2010-06-07

    I am trying to check if a html document includes script tags that are not empty using regular expressions. The regular expression should match any script tag with a content other than whitespaces or linebreaks. I have tried <script\b[^>]*>[^

  • Django return large file 2009-12-20

    I am trying to find the best way (most efficient way) to return large files from Django back to an http client. receive http get request read large file from disk return the content of that file I don't want to read the file then post the response us

  • How to avoid a SAXParseException using Xerces when HTML file includes mdash? 2009-11-27

    I am using the Xerces implementation within JDK6 to perform XPath queries on an HTML 4.0 transitional document. With the following code: XPath newXPath = XPathFactory.newInstance().newXPath(); XPathExpression xpathExpr = newXPath.compile(expression);

  • PDF form submitted to ASP.NET page creates a return HTML file 2011-10-24

    I have a PDF form that has a 'Submit' button that submits its information to a ASP.NET page. The information is taken and processed into a PDF on the server for storage and later use. This process works fine, however after the form is done submitting

  • javascript file talk to script in html file 2011-05-02

    Is there a way of calling a function that exists in a HTML file from a .js file? Something like this: HTML file: <script type="text/javascript" src="javaFile.js"></script> <script type="text/javascript"> function doSomething() { };

  • jQuery .load() call doesn't execute javascript in loaded html file 2009-05-20

    This seems to be a problem related to Safari only. I've tried 4 on Mac and 3 on Windows and am still having no luck. I'm trying to load an external HTML file and have the JavaScript that is embedded execute. The code I'm trying to use is this: $("#my

  • how to access the "id',"name" etc. of Loaded URL in iframe from the HTML file 2011-03-31

    I have an Iframe.html file : <body onload="alert('frame 1 loaded');"> <div> This is frame 1 content </div> <a id="a1" href="Sample.html"> click</a> </body> Sample.html <body> <ul id="list1"> <li name

  • How do I add HTML code to a .html file from another file? 2011-06-12

    I'd like to input some code, for example a menu in HTML from another file so that I can edit that menu and then all the menus for all the sites would change as they'd be linked to that page. Is there a way to do so without making all the pages .php?

  • PHP exit() from within included script, exit parent script? 2011-06-13

    In PHP, if I use the include() or require() functions to start running code in another script, is there a way to terminate the parent script from within the child? So say I have this in parent.php: require('child.php'); And this in child.php: exit();

  • Internationalizaton of HTML Files 2011-08-24

    I am developing a project and uses HTML files (not JSP or any other technology at client side). I use JQuery for scripting. I have tables, columns, and many fields that have "text" on them. How can I internationalize my web page with JQuery? I mean I

  • Asp.Net MVC Can't get .html files or .xml files 404 error? 2009-03-13

    How do I return .html files or .xml files that are in folders in the view? I'm using jquery which request a static Html file via ajax and insert the results into a div and it keeps giving a 404 error any idea? Thanks --------------Solutions----------

  • How do you submit javascript code to a html file in ipad or iphone environment? 2010-12-08

    In the iphone or ipad environment ,how to submit the javascript code to a html file,such as I want to sumit flow code to a html file <script type="text/javascript"> function directTo(username,password) { document.forms['lzform'].form_email.valu

  • How to find all files, including hidden and system files 2011-07-25

    I need to create a full list of the files and sub-directories in a directory. DirectoryInfo.GetFiles() does NOT find all files; hidden files, at a minimum, seem to be missing. (There may also be a problem with permissions, as I can't look inside some

  • how to load an another html file on a button click in jquery mobile 2012-01-04

    I am creating an application in phonegap using the jQuery mobile framework. In my index.html file I have a two text boxes to accept username and password. When I click on the submit button it calls a function submitBtn() that checks whether the usern

  • jQuery AJAX request internet explorer php file -> NO / html file -> YES 2012-04-20

    I have the following jQuery code and a mindbreaking problem in internet explorer, where else... $.ajax({ type: "POST", url: "test.php", //url: "test.html", dataType: "text", cache: false, error:function(xhr, status, errorThrown) { alert(errorThrown+"

  • To put the output of a server side script into an HTML file, should you use #include or #exec? 2009-10-23

    If I want to insert the output of a script into an HTML file using server side includes, is it better to use <!--#include virtual="/cgi-bin/myscript.py" --> or <!--#exec cmd="python /cgi-bin/myscript.py" --> ? --------------Solutions-----

  • How can I include python script in a HTML file? 2010-11-12

    How do I put this python script: a = ['f','d','s','a'] x = -1 scope = vars() for i in a: scope['x']+=1 print a[x] inside of a html file? --------------Solutions------------- Something like this, if you want to create an html, not necessarily display

  • HTML JavaScript Include File Variable Scope 2009-04-15

    If I include a JavaScript file in my HTML page, do the variables declared in my JavaScript file also have scope in my <script /> tags in my HTML page? For example, in my included JS file, I declare a variable: var myVar = "test"; Then inside my

  • Plot a graph in the html file using Django 2011-04-04

    I am doing a monitoring system using Django. In my views file, I have defined one class called showImage which collects the information necessary to plot a graph using matplotlib. At the beginning, I just stored the image in a string buffer to repres

  • Can't figure out how to include *.html files within a site-packages folder 2011-04-17

    I cannot figure out how to write my setup.py script in order to include *.html files within the installed package. Here is my attempt: import os from setuptools import setup, find_packages setup(name='django-testapp', version='0.1', author='RadiantHe

  • How do I include raw HTML files in Symfony2/Twig templates? 2011-10-05

    I'm working on a project in Symfony2 and I have several small pieces of html that need to be included in one of my main views. According to the official Twig documentation I should be able to simply use {% include 'filename.html' %} but in Symfony un

  • How do I call php script each time html file loads? 2011-10-30

    I have php script that counts web site visits. I need to call that script each time my html page loads. How do I do that? --------------Solutions------------- If it's a PHP page, you can include/require a page in to another PHP page using require or

  • Serving html files in /var/www alongwith Django over Apache 2011-12-23

    I got my Apache Mod_WSGI and Django working following http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/ with a twist that my 000-default site has the contents <VirtualHost *:80> ServerAdmin webma

  • using normal html files instead of Django tempaltes 2013-05-10

    I have a bunch of html files. I'd like to render them in my Django View without converting them to Django templates. Is this possible? Or is there any code to do the conversion easily? --------------Solutions------------- Actually, you don't have to

  • php includes in html files-directories 2008-11-24

    Do all php include files have to be in an include directory, or is that just an organizational convenience? Can I include files from any directory using the path to that directory? Do html files that contain php includes have to have a php extension?

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.165 (s). 11 q(s)