Django Development BBS---51 Web Course notes (2)

Source: Internet
Author: User

Then the previous section, to add the front-end code, http://4440271.blog.51cto.com/4430271/1663863


First, find a style in http://v3.bootcss.com/getting-started/:


Use http://v3.bootcss.com/examples/navbar-static-top/here

's Style:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/BE/wKioL1WFQVTwd1cmAACJSfowt3I910.jpg "title=" Qq20150620182507.jpg "alt=" Wkiol1wfqvtwd1cmaacjsfowt3i910.jpg "/>

Download the page and add it to:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/BE/wKioL1WFQ6qgE7O8AACFwrMja6g143.jpg "title=" Qq20150620183505.jpg "alt=" Wkiol1wfq6qge7o8aacfwrmja6g143.jpg "/>

, you need to introduce the directory in settings.py after the add is complete:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C1/wKiom1WFQvyiAlMHAAH7JSKFuAY502.jpg "title=" Qq20150620183924.jpg "alt=" Wkiom1wfqvyialmhaah7jskfuay502.jpg "/>


In the Statics directory, there are js,css files in the Web page that need to be copied to the directory by:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BE/wKioL1WFRUrSn0xOAAArCcUMxrk833.jpg "title=" Qq20150620184202.jpg "alt=" Wkiol1wfrursn0xoaaarccumxrk833.jpg "/>

Here are the following:

http://down.51cto.com/4430271

Download the Statics


Here to make some changes to the content of the page. Only the modified content is uploaded here.

For the front end of the introduction, described in detail in: http://4440271.blog.51cto.com/4430271/1663934


Add in url.py

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C2/wKiom1WFbvfR39AQAALKZ7hzC-c524.jpg "title=" Qq20150620214646.jpg "alt=" Wkiom1wfbvfr39aqaalkz7hzc-c524.jpg "/>


To add a view in views.py:


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C2/wKiom1WFf0OwZG5wAAKxNeEVkYA302.jpg "title=" Qq20150620225640.jpg "alt=" Wkiom1wff0owzg5waakxneevkya302.jpg "/>

The page portion of index is basically completed

The process of linking a view to an HTML page is the same, so the subsequent additions are not specifically described, only explained in the code.




Next, add a comment page:

First, the comment page inherits from index

Secondly, the main display of the comment page is the content of the Bbs_detail first, then the content of the comments, and there should be a place to add comments. Using bbs_detail.html to complete this page, we describe each section separately, and in the Last post of the blog, we will give the complete code.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/C1/wKioL1WGb0jA2zXGAAFUr5z2F_8474.jpg "title=" Qq20150621155325.jpg "alt=" Wkiol1wgb0ja2zxgaafur5z2f_8474.jpg "/>


In views.py, the appropriate modules should be added:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C5/wKiom1WGbo-xfqvzAAEuXsrD7QY722.jpg "title=" Qq20150621155624.jpg "alt=" Wkiom1wgbo-xfqvzaaeuxsrd7qy722.jpg "/>


For the comments section

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C1/wKioL1WGduHj0ZvUAAD-waeKfXA329.jpg "title=" Qq20150621162524.jpg "style=" Float:none; "alt=" wkiol1wgduhj0zvuaad-waekfxa329.jpg "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C1/wKioL1WGdyDyOy46AAK0ioZyVrI953.jpg "title=" Qq20150621160521.jpg "alt=" Wkiol1wgdydyoy46aak0iozyvri953.jpg "/>


In the views.py

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/C5/wKiom1WGdSmj2AxeAAG3k3ezy4w158.jpg "style=" float: none; "title=" qq20150621162426.jpg "alt=" Wkiom1wgdsmj2axeaag3k3ezy4w158.jpg "/>

Here, there is a place to explain, that is, content_type_id, he is the database of all the tables are arranged after the ID number of each table, in our project, BBS table is located in the ID number is 7;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C2/wKioL1WGfFCg-3lfAAGi117HN9o996.jpg "title=" Qq20150621164714.jpg "alt=" Wkiol1wgffcg-3lfaagi117hn9o996.jpg "/>


At the same time, add the URL

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C1/wKioL1WGd32AB8QVAAEc1b5gxQQ487.jpg "title=" Qq20150621162830.jpg "alt=" Wkiol1wgd32ab8qvaaec1b5gxqq487.jpg "/>


The results are as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C2/wKioL1WGgJXDEPv5AACc4bvpbyY495.jpg "title=" Qq20150621170710.jpg "alt=" Wkiol1wggjxdepv5aacc4bvpbyy495.jpg "/>



Then the post page and features:

In the page section, we use an online plugin: http://www.tinymce.com/download/download.php

To make the input page more aesthetically pleasing:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/C6/wKiom1WGhk6gVRyPAAKEiVNc5ZQ334.jpg "title=" Qq20150621173857.jpg "alt=" Wkiom1wghk6gvrypaakeivnc5zq334.jpg "/>


Place the downloaded file in the Statics directory

Its usage is: http://www.tinymce.com/wiki.php/Installation

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C2/wKioL1WGiMiyH6ldAAGYDpW-qMk625.jpg "title=" Qq20150621174214.jpg "alt=" Wkiol1wgimiyh6ldaagydpw-qmk625.jpg "/>

Its page effect:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C4/wKioL1WG26-w6ONTAAG9zzHbdJY687.jpg "title=" Qq20150621233554.jpg "alt=" Wkiol1wg26-w6ontaag9zzhbdjy687.jpg "/>


The implementation code section is as follows:


<link href= "/static/css/signin.css"  rel= "stylesheet" >{% extends  ' index.html '  %} {% block page-content %}<!-- Place inside the 


In views.py, get the data from the front end and import it into the database:


Def bbs_pub (Request):     return render_to_response (' bbs_pub.html ') def bbs_ Sub (request):     print request. Post.get (' content ')     title = request. Post.get (' title ')     content = request. Post.get (' content ')     summary = request. Post.get (' summary ')     author = models. BBS_user.objects.get (User__username=request.user)     models. BBS.objects.create (        title=title,         summary=summary,        content=content,         author=author,        view_count=1 ,         ranking=1,        # Created_at=models. Datetimefield (Auto_now_add=true),  #  Date created          #updated_at  =  Models. Datetimefield (auto_now_add=true),  #  Modified date     )      Return httpresponse ("


At this point, the functionality is basically complete, but the system is simply a patchwork of Django content, with many problems, such as event handling.

In the next section, we will give the full code of Bbc_pro and the final display effect.








This article is from the "Thystar" blog, make sure to keep this source http://4440271.blog.51cto.com/4430271/1664068

Django Development BBS---51 Web Course notes (2)

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.