One of the Django blog tutorials: Creating a Web site project

Source: Internet
Author: User

I. Description of the course

1. Course Source

2, the use of the environment

II. Development Environment and Django

1. Development environment

2. Git installation

Git is currently the world's most advanced distributed version control system

sudo: Run the command as an administrator

Apt-get: is the APT package management tool in the Debian Linux distribution (Ubuntu is a Debian-based release)

Linux distributions: Pre-integrated Linux operating systems for general users and a variety of application software

Apt-get Update: Download the list of packages from the repository and update them, otherwise the older versions of the various packages may be installed

3. GitHub creation

Create a GitHub account, new repository, add and configure SSH, and learn simple GitHub-git collaboration with Install-ssh-use-github

SSH (Secure Shell): A security protocol created on the application and transport tiers that provides a secure transport and usage environment for the shell (shell) on the computer

Add and configure SSH: You do not need to enter a user name when you push, if you do not set a password, you do not need to enter a password, and the HTTPS URL will need to verify the user name and password each push

Specific reference: http://www.cnblogs.com/ayseeing/p/3572582.html

4. Django Installation

PIP: Update the programming Language Level Pack (library)

Apt-get: Update system-level packages

5, Bootstrap installation

Temporarily Skip

Iii. Projects and Apps

1. Project Creation

(1) Add django-admin.py to our environment variables, position in

/usr/local/lib/python2.7/dist-packages/django/bin

Open environment variable file

After path= add django-admin.py's position ':/usr/local/lib/python2.7/dist-packages/django/bin ', after saving exit

django-admin.py is the command-line toolset that Django uses to manage Django

(2) Create a Django project

Create a folder First

Enter the following command in the folder to create the Django project

django-admin.py Startproject is used for a given project in the current directory or in the specified directory (because it has already been configured in the environment variable, so there is no need to add python in front)

Name Create Django project directory structure

Install the tree and use the tree to view the directory structure (the tree is used to list the contents of the directory as a graph)

2. Create a Django App

The app in Django is an application module with different functions and different apps.

(1) switch to My_blog directory, execute manage.py to build a aiticle app

Manage.py is a small package for django-admin, can you do something before you deliver it to django-admin?

manage.py Startapp used to create a Django application directory structure for a given application name in the current directory or in the specified directory

(2) Then use the tree to re-view the project structure and discover more aiticle directories and two PYC files (bytecode files generated by the. py file after compilation)

(3) To view my_blog/my_blog/settings.py, locate the Installed_apps column and add the newly created article

3. Running the program

manage.py Runserver is used to start a lightweight Web server locally, localhost represents the local host, and the corresponding IP address is 137.0.0.1,9000 for the port number

Discover no app migrations (Create projects and add fields), use Python manage.py migrate for app migration

The manage.py migrate is used to synchronize the database state with the current model set and the migration set, and the migration is a model that Django uses to synchronize your changes (add a field, delete a model, etc.) to your database

Run the program again, this time running successfully

Launch Browser, enter http://localhost:9000, run successfully

Iv. Summary of commands

One of the Django blog tutorials: Creating a Web site project

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.