In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
With regard to the study of Django, I mainly rely on two addresses, which I hope to share with you:
Http://www.runoob.com/django/django-install.html
Http://djangobook.py3k.cn/2.0/
-
[introduction]
Web development is exciting and creative, as well as tedious and tiresome; python has many web frameworks, but Django is the most representative of the heavyweight frameworks, which can build and maintain high-quality web applications at minimal cost.
In djangobook, the content is rich and powerful, and at first it clearly explains the advantages of the framework:
Python developed web, the most original method is to use the CGI standard (very popular in 1998), first do a python script, output HTML code, save to a .cgi file, access the .cgi file through a browser
1. In this way, each CGI script needs to repeat the code that links to the database, which is complicated.
2. Developers need to pay extra attention to the type of output and shut down the database after completion. The cycle will reduce efficiency.
3. Web designers who have no experience in python development, correct a certain character, cause the whole application to crash, etc.
The framework will solve such a series of unnecessary duplication of effort, so that developers focus on writing code, and do not have to start from scratch.
Django framework adopts MVC software design pattern, namely model M, view V, controller C. The key advantage of this model is that the components are loosely integrated, and each driver has a clear purpose and is independent.
The developers of django guarantee that the major version numbers are backward compatible, that is, 1.1 applications are available for 1.2 and 1.4, but not for 2.0; it was first released in July 2005, and the first official version 1.0 was released in September 2008.
In essence: Django is a set of class libraries written by python. To learn django is to learn pytho programming and understand how the class library works.
Django is written by python, so to install django first make sure that python is installed (it can run any Python runnable environment, including mobile phones)
There are two versions of the default django: the latest official release and the risky backbone version (Trunk); the recommended official release
Install python http://beibing.blog.51cto.com/10693373/1774252
1. Python download address: https://www.python.org/downloads/
2. Download address of Django: https://www.djangoproject.com/download/
[windows install Django]
Download the Django package, extract it and place it in the same root directory as the Python installation directory
Go to the Django directory, execute python setup.py install, and start the installation
Django will be installed in site-packages under Python's Lib.
Then configure the environment variables and add these directories to the system environment variables:
Cpurs Python 33 apprentice Libmobilsitelypackagespacks Djangoth Cposition Python33 Accord Scripts.
After adding, you can use the django-admin.py command of Django to create a new project.
Check whether the installation is successful
Enter the following command to check: enter the python command line
> import django
> > django.get_version ()
If you output the version number of Django, the installation is correct.
[install Django on Linux]
Easy_install installation method
Install setuptools
Yum install setuptools
Easy_install django
Installation method of pip command
Pip install Django can specify the version number and download the default time pip install Django==1.10.3-- timeout 6000
Source code installation method
Download the source package: https://www.djangoproject.com/download/
Tar xzvf Django-X.Y.tar.gz # decompress the download package
Cd Django-X.Y # enter the Django directory
Python setup.py install # execute installation command
Check: after a successful installation, Django is located in the site-packages directory of the Python installation directory.
Enter python or ipython
> > import django
> > django.VERSION
Output version number installed successfully
[install under Mac]
Download the latest stable version: DJango-1.x.y.tar.gz from here, and download it in the list on the right side of the page, as shown below:
Remember that it is the latest official version. Where x.y is the version number. Go to the folder where you downloaded the file and execute the following command:
(/ Users/xxx/Downloads,xxx is your user name by default under Mac)
Tar zxvf Django-1.x.y.tar.gz
You can also download the latest version from Github at https://github.com/django/django
Git clone https://github.com/django/django.git
Installation
Enter the decompressed directory:
Cd Django-1.x.y
Sudo python setup.py install
The following information is output after a successful installation:
……
Processing dependencies for Django==1.x.y
Finished processing dependencies for Django==1.x.y
Then go to our site directory and create the Django project:
Django-admin.py startproject testdj
Start the service:
Cd testdj # switch to the project we created
Python manage.py runserver
……
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
The above information indicates that the project has been started and the access address is http://127.0.0.1:8000/
[Django and database]
In fact, after the installation is successful, you can run it directly, but if you develop a web site, you need to configure a database server.
Django supports four types of databases:
PostgreSQL 、 SQLLite3 、 MySQL 、 Oracle
Optional GIS support of PostgreSQL,Django is recommended if conditions permit, which provides powerful functions for PostgreSQL
For Python2.4 or earlier, you need SQLite 3 instead of version 2. It doesn't matter if you use Python2.5.
In general, we still use mysq mostly, requiring MySQL4.0 or higher version.
Django requires Oracle9i or later
[first project]
Take the Linux system and mysql database as an example:
Create a project: django-admin.py startproject HelloWorld
HelloWorld: the container for the project.
Manage.py: a practical command line tool that allows you to interact with the Django project in a variety of ways.
HelloWorld/__init__.py: an empty file that tells Python that the directory is a Python package.
HelloWorld/settings.py: the setup / configuration of the Django project.
HelloWorld/urls.py: the URL statement of the Django project; a website "directory" driven by Django.
HelloWorld/wsgi.py: a portal to a WSGI-compatible Web server to run your project.
Create an application: python manage.py startapp blog / / this is not a specific introduction
Start service: python manage.py runserver 8000 / / only local connections are allowed
Start the service: python manage.py runserver 0.0.0.0 8000 / / tell the server to listen on any network interface
After that, you can access it on the web by typing ip:8000.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.