Use of the django master page, django
The master page is used to process the same part of the html page to avoid repeated
1. Add a master page
Add the templates folder in the same directory as the manage. py file to save the html file on the master page.
2、 basbase.html, html is as follows:
Use block for placeholder
3. Use the master page on a specific page
{% extends 'Base.html' %}{% block content%}This i
Deploy Django projects in BAE, and deploy django In bae
1. First create an application name on the BAE and purchase a space2. git the application folder to the local device. At this time, the folder will contain three more files: app. conf, favicon. ico, index. py.3. Create a local project: myblog in the application folder, and create a project app: blog in the local project.4. modify the content of the app
This should be the last learning module for Django. And then you need to go into the project to practice.
There are two ways to upload a Django file, one is the traditional IO-flow based operation, and one is encapsulated as an object-based operation.
But either way, you need to first create a directory of uploaded files,
Operation based on Io flow
The configuration in the URLs, based on the submission of
form, that is, set different types of input boxes#set name to text, cls_id as drop-down box classStudentform (Form): Name= fields. Charfield (widget=widgets. Inputtext ()) cls_id= fields. Integerfield (widget =widgets. Select ()) c. Set the contents of the drop-down box choices PropertiesclassStudentform (Form): cls_id=Fields . Integerfield (widget=widgets. Select (choices=models. Classes.objects.values_list ('ID','title')) Note: The value of choices must be a [tuple, (), ()] Type widget
the top layer of not, in the student table notinch(Learn the teacher course student's ID, as well as the group filter out duplicates) # First to find out what the teacher Li Ping taught lessons;--SelectStudent.sid,student.sname fromStudentwhereStudent.sid notinch (
--Selectstudent_id fromscore--wherescore.course_idinch(SelectCid fromCourse left join teacher on Course.teacher_id=teacher.tidwhereTeacher.tname='Mr. Li Ping')
--GROUP by student_id); # - whereGROUP BY has: Advanced
; TD>{{Item.age}}TD> TD>{{Item.email}}TD> TD>{{item.cls_id}}TD> TD> ahref= "/app01/edit_student/nid={{Item.id}}"class= "Glyphicon glyphicon-pencil">Edita>| ahref= "/app01/del_student/nid={{Item.id}}"class= "Glyphicon Glyphicon-trash">Deletea> TD>{#点击删除是一个get请求, to tell the server ID, you can get it through a URL get request, or a URL match to a pass to the
Document directory
CMS
Forum
Debugging
Database Upgrade
Unclassified
Looking for Django resources, the Wiki on the official website is also a good place.
Http://code.djangoproject.com/wiki/DjangoResourcesResources
Django Official Website
Django document
Django step by step was the best getting started tuto
The path to the admin interface is usually set in My_project, using django-admin.py startproject my_projectIn the urls.py file in the directory, you can seeFrom Django.conf.urls import include, urlfrom django.contrib import adminurlpatterns = [ # Examples: # URL (r ' ^$ ', ' My_project.views.home ', name= ' home '), # URL (r ' ^blog/', include (' Blog.urls ')), URL (r ' ^admin/', include ( Admin.site.urls)), URL (r ' ^$ ', ' my_project.
Django 3 Return JSON methodsfrom django.http import JsonResponse, HttpResponsefrom django.shortcuts import renderfrom app01.models import Book# Create your views here.def get_book(request): all_book = Book.objects.all() d = [] for i in all_book: d.append({'name': i.name}) return JsonResponse(d, safe=False)def get_book2(request): from django.forms.models import model_to_dict all_book = Book.objects.all() d = [] for i in a
1 Django Background implementation set input tag properties, set input label default display value, set input input box type#form generates HTML tagsA. Create input input box through form, form label, and submit tag to write on the front end, but the input tag inside the form tag can be implemented in the background; just follow the steps below-views definition Studentform (Form) class-The Views view function passes the form instantiation object to th
Example of checking box usage in Django development, django example
This example describes how to use the check box in Django development. We will share this with you for your reference. The details are as follows:
1. query check boxes for database Traversal
1. query all tags of a database using python
# Add def add (request): if request. method = 'get': tags = T
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
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.