Django framework (1): installation and deployment

Source: Internet
Author: User
Tags postgresql django website

As the most popular Web framework in Python, Django is trying to deploy it today. Like other frameworks, we mainly learn their naming rules and APIs. To use a network framework. You must be familiar with Python before using Django.

Django installation:

I chose to install it from the source code, and get the source code through GitHub for installation.

     git clone https://github.com/django/django.git

Root permission:

Python setup. py install

Next, check whether Django is successfully installed.

import djangodjango.VERSION

Output:

(1, 6, 0, 'alpha', 0)

Install a database: Django Web applications generally require a database to support, and a database driver needs to be installed before using the database. Supports the following four types of databases: PostgreSQL (http://www.postgresql.org) sqlite3 (http://www.aqlite.org) MySQL (http://www.mysql.com) Oracle (http://www.oracle.com) is now more mainstream database MySQL, prior to contact SQLite more lightweight database, this is the most advanced development environment for MySQL. Install MySQL from the source, and set the root password after installation.
 mysqladmin -uroot -p -h localhost password passwd

If necessary, you can modify/etc/MySQL/My. CNF to configure MySQL.
Then start MYSQL:

lrqrun@lrqrun:/etc/init.d/mysql start

Test whether the installation is successful:

lrqrun@lrqrun:~/work/Django$ mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 39Server version: 5.5.28-0ubuntu0.12.04.3 (Ubuntu)Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> 
Deployment of DJANGO: Create your working directory:/home/username/djcode to the directory you created, run the command django-admin.py startproject mysite to create a directory named mysite under your current directory that contains the following files: mysite/manage. PY mysite/_ init __. PY settings. PY URLs. PY wsgi. PY * _ init __. PY: Let Python treat this directory as a file required by an Development Kit (that is, a module. This is an empty file. You do not need to modify it. * Manage. py: a command line tool that allows you to interact with this Django project in multiple ways. Type python manage. py help to see what it can do. You do not need to edit this file.
Usage: manage.py subcommand [options] [args]Options:  -v VERBOSITY, --verbosity=VERBOSITY                        Verbosity level; 0=minimal output, 1=normal output,                        2=verbose output, 3=very verbose output  --settings=SETTINGS   The Python path to a settings module, e.g.                        "myproject.settings.main". If this isn't provided, the                        DJANGO_SETTINGS_MODULE environment variable will be                        used.  --pythonpath=PYTHONPATH                        A directory to add to the Python path, e.g.                        "/home/djangoprojects/myproject".  --traceback           Print traceback on exception  --version             show program's version number and exit  -h, --help            show this help message and exitType 'manage.py help <subcommand>' for help on a specific subcommand.Available subcommands:[auth]    changepassword    createsuperuser[django]    cleanup    compilemessages    createcachetable    dbshell    diffsettings    dumpdata    flush    inspectdb    loaddata    makemessages    runfcgi    shell    sql    sqlall    sqlclear    sqlcustom    sqlflush    sqlindexes    sqlinitialdata    sqlsequencereset    startapp    startproject    syncdb    test    testserver    validate[sessions]    clearsessions[staticfiles]    collectstatic    findstatic    runserver
* Settings. py: settings or configurations of this Django project. View and understand the available setting types and their default values in this file. * URLs. py: Set the URL of the Django project. It can be viewed as the directory of your Django website. Currently, it is empty. * Wsgi: configuration file of the wsgi web service framework of the Django project. Run the development server: Run Python manage. py runserver in the current directory to start the server. By default, the runserver command starts the development server on port 8000 and only listens to local connections. To change the server port, you can pass the port as a command line parameter: Python manage. py runserver 8080
Validating models...0 errors foundDecember 15, 2012 - 00:09:42Django version 1.6, using settings 'mysite.settings'Development server is running at http://127.0.0.1:8080/Quit the server with CONTROL-C.
You can also specify an IP address to listen to any network interface. Python manage. py runserver 0.0.0.0: 8080

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.