Django Chinese-style static files (css, javascript)

Django Chinese-style static files (css, javascript)

Using css, Javascript in Django templates Test environment (r’^css/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘/var/www/django-demo/css ‘}),(r’^js/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘/var/www/ django-demo/js’}),(r’^images/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘ /var/www/django-demo/images’}), Use the following method in the template: Note: os. path.dirname(globals()[“__file__”]) to get the path of the current file, such as (r’^css/(?P.*)$’, ‘django.views .static.serve’, {‘document_root’: os.path.dirname(globals()[“__file__”])+’/css’}), You can use os.path.abspath() The function returns the absolute path of this path. ============== To reference static files such as css, js, gif, etc. in django’s template file, first create a setting.py The DEBUG switch is turned on. 1. Create a directory to store static files in the project directory, such as: medias2. Add a line to url.py patterns: (r’^site_media/(?P. *)$’,’django.views.static.serve’,{‘document_root’:settings.STATIC_PATH}), Also from django.conf import setting3. Add a line to setting.py: STATIC_PATH=’./medias’ After setting this, you can reference the static files stored in media in the template file, such as: Online environment The use of css cannot be avoided in web projects developed with Django , Javascript, js and other static files. As for the processing of these static files, Django’s official website writes: Django itself doesn’t serve static (media) files, such as images, style sheets, or video. It leaves that job to whichever Web server you choose. That is to say, Django itself…

JavaScript, PHP, Golang, Haskell, Elixir, which is the best programming language?

[CSDN Editor’s Note] Which language is the best programming language in your mind? Author | Michele Riva Translator | Crescent Moon Editor | Ouyang Shuli Produced by | CSDN (ID: CSDNnews) The following is the translation: Over the past few years, I’ve had the opportunity to try out a number of different programming languages ​​. I really enjoy learning different languages, methods and paradigms. I am a curious person and have always been fascinated by programming languages. Every programming language is different. In this article, we discuss the advantages and disadvantages of the following five programming languages. Javascript Haskell Go PHP Elixir Javascript Advantages Quick prototyping: You can use Javascript to quickly write some prototypes to verify your ideas. You can even use Node.js to build a proof of concept for the backend in minimal time. Flexibility: Javascript is growing in popularity, aided by the metaprogramming capabilities of ES6. However, even if you don’t use these functions, you can write some very common functions through Javascript and use it to write clients, servers, and even mobile applications (such as React Native, etc.). Community: The Javascript community is great. Every time you encounter a problem, you can find the answer through…

In Web website building technology, what are HTML, HTML5, XHTML, CSS, SQL, JavaScript, PHP, ASP.NET, and WebServices? –

There are many technologies for building websites, such as HTML, HTML5, XHTML, CSS, SQL, Javascript, PHP, http://ASP.NET, Web Services, browser scripts, server scripts, etc. What’s the difference? Novices don’t understand anything and want to clarify the relationship and application scope of all these technologies. Reply content: A semester ago, I had almost no idea what these were like the original poster. After a semester, I almost understood them all. Let me talk about my own understanding.> <Since I haven’t been in contact for a long time, I welcome corrections if there are any mistakes~ First of all, you need to know what the process of website access is:Suppose you enter the address of this question in the browser address bar http://www.zhihu.com/question/22689579 You might as well integrate the technologies you mentioned into the development process of the Web. If you look at them from a technical and historical perspective, you will know the background of the birth of these technologies and the problems they solve. Refer to an article I once wrote: History of the Development of Web Development Technology. 1. The birth of the Web When it comes to the Web, one word that must be mentioned is “Internet”. Web…

JavaScript, implementation of the function of moving the select tag element left and right

Design a piece of code through Javascript to achieve the following functions. The initial interface is as shown below. Select several options in the left label and then click –> to move them to the right frame and the left options disappear. After clicking ====>, all the options on the left will be moved to the right. After clicking on a few options on the right, and then clicking <—, these options will be moved to the left. Click <====, and the options will be moved to the right. All options are moved to the left. The code is as follows: one two three four five six ” Onclick=”add()”> ” Onclick=”addall()”> <input type="butoon" value=" <input type="butoon" value=" seven The results are as follows The above is the entire content of this article. I hope it will be helpful to everyone’s study and I hope you will support me a lot.

Django Chinese-style static files (css, javascript)

Django Chinese-style static files (css, javascript)

Using css, Javascript in Django templates Test environment (r’^css/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘/var/www/django-demo/css ‘}),(r’^js/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘/var/www/ django-demo/js’}),(r’^images/(?P.*)$’, ‘django.views.static.serve’, {‘document_root’: ‘ /var/www/django-demo/images’}), Use the following method in the template: Note: os. path.dirname(globals()[“__file__”]) to get the path of the current file, such as (r’^css/(?P.*)$’, ‘django.views .static.serve’, {‘document_root’: os.path.dirname(globals()[“__file__”])+’/css’}), You can use os.path.abspath() The function returns the absolute path of this path. ============== To reference static files such as css, js, gif, etc. in django’s template file, first create a setting.py The DEBUG switch is turned on. 1. Create a directory to store static files in the project directory, such as: medias2. Add a line to url.py patterns: (r’^site_media/(?P. *)$’,’django.views.static.serve’,{‘document_root’:settings.STATIC_PATH}), Also from django.conf import setting3. Add a line to setting.py: STATIC_PATH=’./medias’ After setting this, you can reference the static files stored in media in the template file, such as: Online environment The use of css cannot be avoided in web projects developed with Django , Javascript, js and other static files. As for the processing of these static files, Django’s official website writes: Django itself doesn’t serve static (media) files, such as images, style sheets, or video. It leaves that job to whichever Web server you choose. That is to say, Django itself…

JavaScript

JavaScript

Cross-platform, operated on the client Writing location Event-driven Java Script Common events Demo Java Script events

javaScript, PHP connection to takeaway ticket machine printer solution (calling Jiabo, Xinye, etc.)

Foreword: Current development requires a computer to directly connect to a takeout receipt machine to print receipts and access various information. Using HttpPrinter finally solved this problem. Effect: PHP and Javascript directly connect to the ticket machine and automatically issue tickets. Supported small ticket machines: The ones currently tested include: computer A4 printer, Jiabo GP58MBIII (USB direct connection), Xinye xp-58IIL (USB). In principle, it can support all USB-connected ticket machines. The current template is set according to 58MM. // Print POS Ticket Begin Function Print (ARR) { var ip = $ (“#ip”). Val (); VAR PORT = $(“#port”).val(); if(ip==””||port==””){alert(“ip,port cannot be empty”); return false;}<br /// Treatment of food data var Foodsjson = & # 39; & # 39; for (var I = 0; i { Foodsjson = Foodsjsjson + & # 39; {“” shangpname”:'+arr.foods[i].name +',”shuliang”:'+ arr.foods[i].count+', “je”:& #39;+ arr.foods[i].price+'},';         }           var msg = '{'                                        '”method”:”' + 'printreport' +'”' /*Report type gridreport fastreport reportmachine If empty, it will default to gridreport */ +',”ReportType”:”' + 'fastreport' +'”' /*Report type gridreport fastreport reportmachine If empty, it will default to gridreport */ +& # 39;, “Reportname”: “& # 39; +& # 39; AAALQS.FR3 &…

JavaScript, jquery closure concept analysis_javascript skills

But I use Javascript often, so I need to understand the concepts involved. In fact, the concept of closure in Javascript is very simple, that is, the function uses external variables and can be obtained without passing parameters. For example: The code is as follows: The first function sayHello does not pass parameters and directly uses the sMessage variable. This is called a closure. The second function is more complicated. There is a doAddition in it which is also a closure function. It does not require parameters and directly obtains iNum1, iNum2 and the external variable iBaseNum in the execution environment. The third function can protect the access of the i variable, and always save i in the memory, and can continue to increase. (A classic use of closures) The closures in jquery are similar, let’s give an example first You may ask The code is as follows: (function($){ $(“p p”).click(function( ){alert(“cssrain!”)}); })(jQuery); //A closure What is this way of writing? Don’t worry, I also asked upc for advice, and then I understood a little bit. The $ here is just a formal parameter, but jquery is a global variable, so it will be executed automatically without calling the function,…

Parse the description of DHTML, JavaScript, DOM, BOM and WEB standards_Basic knowledge

Parse the description of DHTML, JavaScript, DOM, BOM and WEB standards_Basic knowledge

DHTML:It is not a new language, but the product of the combination of HTML, CSS and Javascript. DHTML includes the following 3 meanings: (1) Mark the web page into various elements through HTML (2) Use CSS to design the layout style between elements and control the position of each tag (3) Use js to control Each tagJavascript consists of three parts: (1) ECMAScript is a scripting programming language standardized by the European Computer Manufacturers Association (ECMA) through ECMA-262. ECMAScript defines all features, objects and methods of a scripting language, and other languages ​​can implement ECMAscipt as a baseline for their functionality. ECMAscript includes Javascript, ActionScript and ScriptEase(2) DOM, which is an interface independent of browser, platform and language, allowing users to access other standard components of the page. DOM resolves the conflict between Netscape and Microsoft, providing a standard method for Web developers to conveniently access data, scripts and presentation layer objects in the site. (3) BOM, which can access and operate the browser window. Using BOM technology, web developers can move the window, change the status bar and perform some operations unrelated to the page content. It The characteristics are as follows: Pop up a new browser window, move…

What are some frequently misused HTML, JavaScript, and CSS elements, methods, and attributes?

What are the elements, methods and methods of HTML, Javascript and CSS that are often misused? Attributes? In the past, when I wanted to make an element (such as input) read-only, I used disabled, but later I found that this was wrong. Because in HTML, if an element is set to disabled, its value will not be sent to the server. The correct approach should be to use readonly. So besides disabled, what other things are often misused in web development? Reply content: Let’s just talk about CSS. Float:left/right or position: absolute is followed by display:block, which is superfluous (relationship between the three: Visual formatting model) 5. Do not use the lang attribute or lang Attributes are written as zh-CN and other obsolete usages No one talks about JS? Well, I heard another strange statement today, so I decided to write a few sentences. It can be said that the following points are all taken for granted because they were taken for granted but were not verified. The wrong way of writing has been spread like this. There is no semantic difference between if(value) and if (!!value). I object to the way if (!!value) is written. The same boring way…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索