Django model (1), Django model (Models in Django (1)
1. Basic Development Process
1. Configure the database
2. Define model class: A Model class corresponds to a data table in the database.
3. Generate a migration File
4. Execute the migration file generation data table
5. add, delete, modify, and query models
The above content is detailed in the basic pro
Django advanced addition, django advanced
Preface: This blog adds to the previous blog's django advanced tutorial.
I,
The front-end interface is relatively simple (ugly) and has two functions:
Extract the name from the database. For example, book
In the form, enter the name of the book, select the publisher, select the author (select multiple), and click Crea
#!/usr/bin/env python#Run this with#serves by default at#Http://localhost:8080/hello-tornado and#Http://localhost:8080/hello-django fromTornado.optionsImportoptions, define, Parse_command_lineImportDjango.core.handlers.wsgiImportTornado.httpserverImportTornado.ioloopImportTornado.webImportTornado.wsgiImportOsdefine ('Port', Type=int, help="run on the given port", default=80)classHellohandler (tornado.web.RequestHandler):defGet (self): Self.write ('Hel
Django implements paging. django implements paging.
This example describes how to implement paging in django. Share it with you for your reference. The details are as follows:
The Python code is as follows:
#!/usr/bin/env python# -*- coding: utf-8 -*-# Create your views here.from django.shortcuts import render_to_responsefrom winlog.log_dj.models import Winlogfro
[Django] django + able is simple to use in tables, djangodatatable
To use datatable, you must first download the datatable file. The file mainly includes three folders: css, img, and js. how to configure them in django?
First, you must introduce the datatable file in the template in the following format:
Note that the js file in datatables must be referenced
Before we start, let's take a picture to understand the internal Django process, and we know that Django uses the MTV architecture, and the first part today is the controller, called the routing system in the Tornado framework, that maps the URLs to the appropriate processing logic. In Django, which is view processing, called views, and presumably, I'll go over a
performance Layer status ". Specifically:GET is used to obtain resources, POST is used to create resources (or update resources), PUT is used to update resources, and DELETE is used to DELETE resources.We should be able to understand this. If you want to have a deep understanding, you need to learn it slowly during development.
I have written this series of blog articles while learning, so there may be some misunderstandings here. Thank you for your attention ~ The main purpose is to exchange,
Django many-to-many relationships, django many-to-Relationship
Django 1, 1.7
Use ManyToManyFiled to define multiple-to-multiple relationships.
In this example, the Article can be published on multiple publications, and the Publication can have multiple Article objects.
from django.db import modelsclass Publication(models.Model): title = models.CharField(max
Django-admin.py startproject mysite
This command creates a mysite directory in the current directory.
Django-admin.py file in c: \ python27 \ Lib \ Site-packages \ Django \ bin folder, you can add this directory to the system path.
Django has a built-in lightweight Web server.
If you enter the mysite directory, enter t
Django --- media static file configuration global variables, django --- media staticMedia static file configuration
Static files are mostly used to store data used to render front-end pages, and media is used to store client uploads or other files.
Add path to setting. py
MEDIA_ROOT = (OS. path. join (BASE_DIR, 'blog01/media') MEDIA_URL = '/media/' # Alias, which can be written at will
Add Route Allocation
In django, the Data Query condition is that the table columns corresponding to the foreign key in the table should be searched ?, Django table
1. Generally, the condition for finding data in a table is the existing data type in python. You can use the dot operator to directly find the data. If the condition is a column in the table corresponding to a foreign key column, how do I query data? For example
clas
First, Templates filterFilters are part of the Django template languageModify variables in a template to display different content{{value | filter}}Example: {{list_nums | length}} indicates the length of the list{{Value | filter | filter | filter}} can be superimposedDjango Template If there is a non-existent variable, will not error, will only give a null valueSo modify add_article.html Remove {{% if *%}} Add filter defaultDOCTYPE HTML>HTML>Head>
To implement the ThinkPHP online translation function, you must register an API key in the Baidu Developer Center. The specific implementation code is as follows:
Action Code:
Html code:
First find the httpd.conf under Apache2 's conf file and add the following information:Alias/static/e:/wamp/apache24/www/static/static> Options followsymlinks allowoverride None Require all granted Settings for the setting under the Django Project:# Static files (CSS, JavaScript, Images)# https://docs.djangoproject.com/en/1.8/howto/static-files/' /static/'staticfiles_dirs ="static"),) [Django
Solution for Django to forget the Administrator account and password: django account
After looking at the Django tutorial to build a website, I forgot my first account and password. As a result, you cannot log on to the Management page and cannot proceed.
:
I can't find many methods on the Internet. I finally use the method of creating a superuser, but the acc
Django file storage (1) default storage system, django file storage
Django's default file storage system 'django. core. files. storage. filesystemstore' is a local storage system, determined by the DEFAULT_FILE_STORAGE value in settings.
ClassFileSystemStorage(Location = None,Base_url = None,File_permissions_mode = None,Directory_permissions_mode = None)
The File
1. Installationlinaro-django-paginationSettingsInstalled_apps = ( # ... 'linaro_django_pagination',) Middleware_classes= ( # ... 'Linaro_django_pagination.middleware.PaginationMiddleware',) Template_context_processors= (#in 1.7 This option is canceled by default, seemingly. How we go about loading in templates and views is an important issue. 'Django.contrib.auth.context_processors.auth', 'Django.core.context_processors.debug', 'd
Inheritance of Django templates, django templates
When using djangofor webdevelopment, a basic framework template base.html will be constructed in the past, and then the common parts and definition blocks of the websites it contains will be reloaded in its subtemplates.
First, create a base.html file. The source code is:
This base.html template defines a simple html framework document, which will be used o
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.