have been optimizing the code of their own blog, yesterday, the CSS style sheet was separated, as a staticFile, but didn't learn how Django uses static files, after some googleFinally solved.There are two ways Django uses static files, one that is deployed on Django, and the otheris deployed on Apache, the previous method has a certain flaw, inefficient, and will
System version:CentOS 7.3Apache 2.4Django 1.11Problem descriptionThe Django project involves the upload operation, the upload file name contains Chinese, if use Runserver start the service, no problem!If you deploy the Django project to the Apache server, if you upload a file that contains Chinese, the error is:ASCII ' codec can ' t encode characters in position
Currently, Apache and mod_python are the most robust combinations for deploying Django on production servers. Mod_python is an Apache plug-in embedded with python in Apache. It loads Python code into the memory when the server starts.
Django requires support for apaceh 2.x and mod_python 3.x.
For Apache configuration, see: http://www.djangoproject.com/r/apache/docs/
Dep
First, preparatory work
1. Create a space on your own server or virtual machine (this case uses Ubuntu's Aliyun server)
mkvirtualenv [space name]
* * View all space * *
Workon * * Enter a space * *
Workon space Name2, upload the code to the server
3, run the project to see will be normal?
Python manage.py runserver
4, turn off the debug mode (under the project's settings.py file)
DEBUG = False
5, modify allow access to all places
**settings.py file * *
allowed_hosts = [' * ']
6. Implement a
After the last chapter, we've created the good one Django app, and then we're ready to refine it.First, let's start with some basic concepts.
Each application created in Django is made up of Python packages that follow certain conventions. Django comes with a utility that automatically generates the basic dire
[Django] deploy with fastcgi
The django official team has begun to deploy the django application with fastcgi. As a user who has used it before, I should post a configuration to commemorate it.Under Project
#! /bin/shcase "$@" in start) python manage.py runfcgi
In the previous chapter, we completed the basic functions of admin, but the appearance of it is too ugly, then we will try to change it ~
If you want to change it, you'll use Django's templating system. Because admin is a Django-brought app, he uses a Django-brought template system.
First you need to create a template folder in the project, you can
[' DJANGO_SETTINGS_ MODULE '] = "myproject.settings" from django.core.servers.fastcgi import runfastcgirunfastcgi (method= "threaded", Daemonize= "false")
Restart the newly generated process server
If you change any of the Python code on the site, you need to tell fastcgi. However, this does not need to restart Apache, but only need to re-upload mysite.fcgi or edit the file, so that the change time has changed, it will automatically help you restart the Dja
()1 vim/var/www/html/buglist/buglist/settings.py1 allowed_hosts = [www.example.com',] ----Add your own domain name1Staticfiles_finders = (2 'Django.contrib.staticfiles.finders.FileSystemFinder',3 'Django.contrib.staticfiles.finders.AppDirectoriesFinder',4#'Django.contrib.staticfiles.finders.DefaultStorageFinder',5 )6Staticfiles_dirs = ('/var/www/html/buglist/static/css',-----Here to change the previous relative path to an absolute path7 '/var/www/html
The first Django app we're going to make a polling site.He is made up of two parts:
A common interface allows users to vote
A management interface, to vote on the deletion.
First of all, you have to create a new project, just one line of code, and Django will automatically do the job for you.Switch the CD to the path you want to store your proje
This document uses fabric to automatically deploy its own Webtools project, saving time on the Go . Fabric Installation
The fabric installation is straightforward apt-get install fabric, but installing on Windows will cause the following error: Missing Visual C + + 9.0. You only need to download the Microsoft Visual C + + Compiler for Python 2.7 installation. When installed, a Fab.exe file is generated in the scripts directory and added to the environ
Just a note, a lot of online tutorials: 1. Modify Nginx configuration file Server{listen80default_server;listen[::]:80default_serveripv6only=on;root /home/ranvane/gwdj;indexindex.htmlindex.htm;#makesiteaccessiblefrom http://localhost/server_namelocalhost;access_log/home/ranvane/ gwdj/python.access.log;error_log/home/ranvane/gwdj/python.error.log; location/{proxy_passhttp://127.0.0.1:8000; proxy_set_headerHost $host; proxy_set_header X-Real-IP $remote _addr;proxy_set_headerx-forwarded-for$ Proxy_
tornado_main.py ├──tornado_main.py~ └──ts ├──_ _init__.py ├──__init__.pyc ├──manage.py ├──settings.py ├──settings.py~ ├──settings.pyc ├──tornado_main.py ├──tornado_main.py~ ├──urls.py ├──urls.py~ ├──urls.pyc ├── views.py ├──views.pyc └──wsgi.pyQingming Festival ~ ~Chinese Traditional festivals, noon in dormitoryTomorrow will be class again, come on Oh!Reference Documentation:Official docum
Tags: file sudo remote etc access right get address Ubuntu effective1. Install MySQL and plugins:sudo apt-get install mysql-server mysql-clientsudo apt-get Install Libmysqld-devsudo apt-get install Python-devIn this process he will prompt you to enter the root password and confirm the password.Install the python and MySQL connection pluginMysqlclient2. Configure MySQL remote access permission (user name password self-modification)GRANT all privileges on * * to ' user name ' @ '% ' identified by
In Django, files such as CSS and pictures need to be placed under the static file.Then create the following files in turn:Polls/static/polls/style.cssThen modify the Style.css as follows:Li a { color:green;}Next, add the following code to the polls/index.html:{% load staticfiles%} rel= "stylesheet" type= "text/css" href= "{% static" Polls/style.css '%} '/>EffectNext add a background image:Add the image background.gif under directory C:\mysi
As a little white with Python, starting to learn Django is doomed to a long way, documenting the learning process problems and solutions.Thanks to the selfless dedication of the "self-Improvement Academy", after installing Django 1.9.12 in the tutorial, try to create a new project with Python manage.py Startapp App-name has been unable to build the
, version=1.0.0.0, culture=neutral , publickeytoken=31bf3856ad364e35 " /> assemblies> compilation> .... -->system.web> II: Deploy an ASP. MVC3 Application to IIS 6.0Related Settings for 1.IIS 6.0In fact, it's very simple. The MVC suffix sets the mapping handler. Make sure that IIS 6.0 can process ASP. NET 4.0 and then set the ASP. NET version to ASP. NET 4.0 for the specific site and then set IIS to direct the ASP. Then set the applicati
Make sure your published the friendlyhello image you created by pushing it to a registry. We'll be using the that shared image here.
Be sure your image works as a deployed container. Run This command, slotting-your info for username , repo , and tag : docker run -p 80:80 username/repo:tag , then visit http://localhost/ .
The final version of from part docker-compose.yml 5 handy.
That is Compose file works just as well in production as it does on your machine.Here, we'll go through s
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.