Day20 project+ View News list + likes + image verification code + comments and multilevel reviews + Admin + webSocket + kindeditor

Source: Internet
Author: User

Day20
Review:
1. Request Life cycle

2. Middleware
MD = [
"File_path.classname"
]
Process_request "dispensable" Process_response "must have"
Process_request Process_response
Process_request Process_response
Process_request Process_response
Process_request Process_response

Routes, functions
3. Routing system
A. Func-/index/
B./index/(\d+), func ()
C./prev/, include (' Xxx.urls ')
D./detail/, Func-N1
{% URL n1%}
Reverse (' N1 ')
4. View functions
A. FBV
def index (Request):
Request. POST
Request. GET
Request.method
Request. FILES
Request.body
Request. Cookies
Request.session
Request.path_info
Request ...

return render
Return redirect
Return HttpResponse

B. CBV
Class Foo (view):
Def Dispatch
Pass

def get

...
5. Template Engine Rendering
A. Django background finishes rendering all work
B. Dictionaries, tuples, lists:.
C. simple_tag

6. Database Operations
Pymysql
-Write your own SQL statement
Orm
-Classes and objects complete all operations of the database

-Create Class
-Single Table
-One on one
-one-to-many
-Many-to-many
Operation
...

7. Paging


8. Ajax Submissions
$.ajax ({
Url:
Type
Data
DataType:
Headers
Success:function (ARG) {


}

})


9. Django Form Components
Class
Dictionary = ()


obj = Foo (reqest. GET)
Obj.is_valid ()

10. Serialization



11. Other:
Csrf
Cache
Signal

Today's content:
1. Project

Fill data (Admin):
admin.py
From repository Import models

Admin.site.register (models. UserInfo)
Admin.site.register (models. Comment)
Admin.site.register (models. Favor)
Admin.site.register (models. News)
Admin.site.register (models. Newstype)
Create user
Python manage.py createsuperuser
Root
root!23456

Browser:
Htt P://127.0.0.1:8000/admin

Admin Displays:
Class News (models. Model):
Nid = Models. Autofield (primary_key=true)
User_info = models. ForeignKey (' UserInfo ')
Class Meta:
Verbose_name_plural = ' News ' # table name

Def __str__ (self):
return Self.title # line display content
Captcha:
1. PIP3 Install Pillow
2. Check_ code.py and Monaco.ttf "Project and Directory"
3. 4.
def xxxxx (request):
Img_obj, code = Ac.create_validate_code ()
stream = Bytesio ()
IM G_obj.save (Stream, ' png ')
request.session[' check_code '] = code
Return HttpResponse (Stream.getvalue ())
2. View the News list
3. Like
Backend:

Frontend:
position:relative; absolute;
      
Function ZMM (ths,txt) {
var fontSize = 5;
var left = 5;
var top = 5;
var opacity = 1;

var tag = document.createelement (' span ');
tag.innerhtml = txt;
Tag.style.position = "absolute";
Tag.style.fontSize = fontSize + ' px ';
Tag.style.left = left+ ' px ';
Tag.style.top = top+ ' px ';
Tag.style.opacity = opacity;
$ (THS). append (tag);

var obj = setinterval (function () {
FontSize = fontSize + 5;
left = left + 5;
top = top-5;
opacity = opacity-0.1;
Tag.style.fontSize = fontSize + ' px ';
Tag.style.left = left+ ' px ';
Tag.style.top = top+ ' px ';
Tag.style.opacity = opacity;
if (Left > 60) {
Clearinterval (obj);
Tag.remove ();
}
},100);
}

4. Image Verification Code
5. Comments and multilevel reviews (**********)
A. Structured data
B. Recursive generation of HTML

7. Background Management
-Simple menu (for fixed number of menus)
-Dynamic Menu
Current URL:/backend/host/

A. Structured data
B. Recursive generation of HTML


6. WebSocket
Http://www.cnblogs.com/wupeiqi/p/6558766.html

8. kindeditor[plug-in]----owed
-Height width
-Item
-
Uploadjson: '/kind/upload_img/',
Extrafileuploadparams: {
' Csrfmiddlewaretoken ': ' {{csrf_token}} '
},
Filepostname: ' Fafafa '


def upload_img (Request):
"""
File Upload
:p Aram Request:
: return:
"""
obj = Request. Files.get (' Fafafa ')

DIC = {
' ERROR ': 0,
' URL ': '/static/imgs/20130809170025.png ',
' Message ': ' Wrong ... '
}

Return HttpResponse (Json.dumps (DIC))


Homework: Finishing Today

Next week content:
1. Alex,
Collaborative development of GitHub
Celery
such as

Day20 project+ View News list + likes + image verification code + comments and multilevel reviews + Admin + webSocket + kindeditor

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.