how can i use Django with html CSS JS? - javascript

I am making a website and through some sources. I find out that Django is for backend and html CSS and JS is for front end.
So I am designing my pages in the later 3 and not started developing the backend.
Is there any way that I can use Django with html CSS and JS? (please suggest an easy method as I am a newbie ,however I am quite familiar with python )

Django would be used to match urls with pages. Specifically you would need to create a view that renders a template (here comes the html) and some static files (css, js). If you wont use a database i would suggest that you use flask which does the thing is described above much more easily.

Related

Optimal way to manage multiple HTMLs with the same code?

I am building my own photography website where dynamic content is the pictures.
Right now, I have seperate HTML files for each page, which is very inefficient when I make any code changes.
I tried javascript to handle the dynamic content, but back and forward navigation doesn't work. I am not sure if php is appropriate as it's server side scripting.
What would be an optimal way to update the dynamic content?
Your question is not clear. It seems that you are simply duplicating each dynamic page to create a static HTML file.
Of course you should stop ASAP this, and you should use a proper framework to manage your dynamic content. Since you have mentioned PHP I suggest you to take a look at Laravel
You could create a route like:
yoursite.com/image/id-image
That can be managed by Laravel by:
Route::get('image/{id}', function($id) {
...
});
What you need it's some sort of templating engine, if you have experience with javascript jade would be a good option for you.

Attach PDF to PDF as attachment (not as a page) via Javascript in HTML (not in Acrobat)

I would like to generate a PDF portfolio using JS from an HTML/CSS page on a local machine. I would use a PDF template file which includes a PDF portfolio Navigator in SWF form. I have successfully accomplished this using C# and a command line program, but can not identify the proper Javascipt components to do this browser-side or pseuo-server with Node.js. Basically, I am looking for something which will allow me to append a PDF to a new or existing PDF via configuration choices and an 'assemble' action using a JS or HTML button. iTextSharp provides the required PDF interaction functionality, but I can not figure out to run this inside an HTML to allow configuration via the HTML/CSS DOM (i.e. checkboxes, text field desciptors, etc...). Does a library with this type of functionality exist?
So you want to create a PDF using JavaScript?
On a quick google search, I found what appears to be a javascript library for creating and manipulating PDFs call jsPDF
If you want information on how to upload files with JavaScript alone, here is an article on how to do that. It also shows you how to use the file element.
For style, I recommend using a CSS Framework is you don't know much about CSS. I personally use Twitter Bootstrap for quickly prototyping things. It's quick and easy, and has good documentation. You can also use this to see how to make a form in HTML. I haven't got any good starter tutorials for HTML off the top of my list, sorry.
If you don't know much about JavaScript, when it comes to getting the options from the form, so that you can use them as configuration options, I'd suggest using the jQuery framework. It'll help you get up and running quickly enough
Note, all of this shouldn't replace basic training in JavaScript and HTML/CSS. Frameworks make things simpler, but if you don't know how to do something without a framework, you're going to have a hard time with a lot of the more complicated things. This goes for every language

Generate pages with javascript

I'm working in a company where we are creating a web app, and we are moving all the legacy Yii PHP controllers to a more dynamic style.
Instead of generate HTML with PHP, the app it's moving to ask data to the java private API and receive JSON to generate HTML elements with Javascript, but there still are elements generated in the PHP code.
My question is: is it viable to use the server code (php, ruby, java...) just to generate some data in json and then create everything via javascript once it's received? (maybe everything but body, head tags :P)
Pros? cons?
If it's not a bad idea, is there any tips? Frameworks (like dust.js, backbone...) advices?
Why should I continue with this idea or why get away from it?
Edit:
Example:
A php generated page (from Yii framework using MVC as said - so not mixing backend and frontend) with the basic information like page header, side menu, footer, and some content without functionality. Once this page is received, the js takes control and adds extra functionality, right?
The other point is:
The same page but PHP not rendering anything but <html><body></body></html> (just the basic stuff, maybe something more like including js files, some headers... you know, the minimum needed) AND setting some javascript variables using JSON objects, with all the information needed by javascript to render the header, menu, body, etc.
So the pattern will be close to the one-page design by js (as backbone, angular.js, etc.).

Client-side solution similar to asp.net master page

I recently started using WebStorm to implement web applications and find the experience much better than using Visual Studio.
I am considering moving the "view" part in mvc to pure html as much as possible without relying on server template engine such as Razor. So that I don't have to open visual studio until server side code is needed.
Google results showed that client side template engines such as Handlebars and Mustache will be able to help generate dynamic html pages. One thing I have not found is that ability to combine "parts" of pages together (like the master page in asp.net) so that we don't need to copy/paste header/footer everywhere.
How do I achieve "master page"-like functionality with client side (i.e. javascript) solutions?
Thanks for your help.
You could try this:
use 'shtml' file to struct your webpage,so that you can reference the include instruction:
<!--#include file="head.html"--><hr><b>Hello,this is body!</b><hr><!--#include file="foot.html"-->
As to 'head.html' and 'foot.html',well,you know what should include in them.Actually,they are 'div' segments~~~

Reusing HTML code with only client side technologies

I am tasked with creating a website using only client side techs such as HTML, CSS and JavaScript. We can't using any server-side tech because the instructor is too lazy to install anything and won't allow us to deploy using something such as Heroku. Is there a way I can do this? In particular I want to create partials for that navigation and footer without having to copy and paste them in every single file.
I know of two different approaches:
1. Using Ajax
You can use ajax to do this - probably with the help of a JavaScript library or framework.
JQuery's load can do things like $('#header').load('header-partial.html');
If you're building something more complex with a lot of views, etc... I'd consider using a MV* javascript framework like Backbone.js or AngularJS.
Check out the AngularJS seed project on GitHub for an example
2. Using a build script
If your site is simple enough that all you want to do is include a header and footer on each page, you should consider doing this as a build step in your deployment process. I.E. complile your html with the partials locally, and upload full pages, with the header/footer code on every html page.
This approach has the benefit of not breaking your site if js is disabled.
For an example, check out html5boilerplate's ant build script

Categories

Resources