Django Introduction:
Django is an open source Web application framework written by Python. The framework pattern of MVC is adopted, namely model M, view V and Controller C. But Django is more concerned with models, templates (Template) and views, called MTV mode, in the actual use of
PYTHON framework-DJANGO Study Notes (4)Just like our first goal, it is very easy to create a webpage to output the famous example: Hello world. The first view Hello world. These are complete functions and import declarations. Input them to the views. py file: 1 from django. http import HttpResponse2 3 def hello (request): 4 return HttpResponse ("Hello World! \ NI
1. Install Python and pip (python, pip install self Baidu, Pip is a tool to install and manage Python packages)2. Configure Python environment variables (both Python and scripts directories need to be configured)3. Installing Django
Python django BASICS (1) and pythondjango Basics
Django introduction:Django is an open-source Web application framework written in Python. It adopts the MVC framework model, namely Model M, view V and controller C. However, in actual use of Django,
set field optional
After fiddling with it for a while, you might find that the management tool has a limit: Editing a form requires you to fill in every field, but in some cases you want some fields to be optional. For example, we want the email field in the author module to be optional, which allows you to not fill it. In the real world, you may not have registered an email address for each author.
In order to specify an optional email field, you simply edit the
Address objects, we call Store.find () to query:
>>> person = store.find (person, Person.name = = U ' person '). One () >>> print "%r,%r"% (Person.id, PERSON.N AME) 1, u ' person ' >>> store.find (address, Address.person = = person). One () >>> Address = Store.find ( Address, Address.person = = person). One () >>> print "%r,%r"% (Address.id, address.address) 1, u ' Address '
Django's ORM
Django is a free open source, tightly embedded ORM to its sys
Start with setting up the environment. As a beginner in Python, a handy compiler is very important. I wanted to use VS to develop Python, but I felt that few companies in actual development would use VS to develop Python, I can't change it to MyEclipse.
1. Download and install Myeclipse.
2. Install Python. The general
Start with setting up the environment first. As a Python beginner, it's important to use vs to develop python, but it feels like few companies in the actual development will use VS to develop python, no way to replace it with MyEclipse.
First, download and install the MyEclipse is skipped.
Second, install Python. The
Foreword: With the release of Django1.4 's second candidate, although Python3 is not yet supported, the Django team is already in the planning, according to the official blog, Django1.5 will be experimental support Python3.
Django, as an excellent open source framework for Python, may not be as much of a compliment as other popular frameworks such as rails, but
1. EstablishDjango project:
Run: django-admin.py startproject hello
You can view the created project file:
_ Init _. py: indicates to the Python compiler that the content in the current folder is a Python project module.
Manage. py: The Python script file works with the Django
from:http://blog.csdn.net/u013088062/article/details/50158239
Create a new project1. ThemeThis section of the tutorial focuses on creating, managing, and running a Django project through Pycharm.Django is an open-source Web application framework written by Python. The MVC Software Design pattern is used, i.e. model M, view V and Controller C.2. Preparatory work(1) Pycharm is 3.0 or higher.(2) At least
Deployment of Nginx + uWSGI + Django + Python application architecture
The CentOS 6.5 System
1. install and configure nginx and Python
Yum install nginx
Python is installed on 2.6 by default. Upgrade to 2.7. See the tutorial.
2. Install django
Download the latest version:
1. First we want to download Python and Django, and they are as followsPython Address: https://www.python.org/Django Address: https://www.djangoproject.com/2. Install the Python environment first before you install Django.A. After downloading the Python installation package,
registered to the background. Admin background to manageThe admin.py below App01 writes the following: from Import Admin # Register your models here. # Importing the APP01 database module from Import Models # register the class we created and Access Admin.site.register (models) through him. UserInfo)5. Enter Admin to manageURL address http://127.0.0.1:8000/admin/# Create an administrative user Python3 manag.py Createsuperuser Enter user name: Email address Password: Confirm password:2. A
1. DownloadDownload https://www.djangoproject.com/download/latest version. The latest version is 1.6.Ii. installation:Decompress the downloaded django-1.6.tar.gz file to drive D. Then run win + X command prompt to go To the Django directory of drive D and run the setup. py install command to execute the installation.After the installation, we found that Django wa
Installation environment: Python version 2.7.5, win7 systemInstall Djangohttps://www.djangoproject.com/download/Official Download django-1.5.5.tar.gz1, after decompression (my directory is D:\myapp\Django-1.5.5)The 2,dos command executes the command to the Django-1.5.5 directory just after extracting the
Python-Django-part 1, pythondjango-partPython manage. py syncdb has been replaced in django1.7; Use python manage. py migrate is used to move the library; Delete and uninstall django in cd/usr/local/lib/python2.7/dist-packages/delete and install the directory related to django
import render_to_responsedef search_form (Request): return Render_to_response (' Search_ Form.html ')
This view function can be placed anywhere in the Python search path. For the sake of discussion, let's put it in the books/views.py.
This search_form.html template may look like this:
Search
And the Urlpattern in urls.py may be this:
From mysite.books Import viewsurlpatterns = Patterns (", # ... (R ' ^search-form/$ ', views.search_form),
This article mainly introduces the form processing example in the Python Django framework. form processing is a basic operation in Django. if you need it, you can refer to the following example about books, authors, and publishing houses:
from django.db import modelsclass Publisher(models.Model): name = models.CharField(max_length=30) address = models.CharFie
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.