Login bbs the project, registration and Home

  1. First analysis table, the table design, SD specific correspondence between (1-to-1 or 1 to many or many to many) used Abstracter, it needs to be configured, settings inside
  2. Registration function
    1. Static configuration file, routing, view functions, forms with the components, the write MyRegForm. Specifies the leading end of the field (Input block is returned to the front end, there bootstap pattern shall add form-control class) and the hook function
      • User name, password, confirm password, email, picture
    2. front end:
      1. Avatar, hoping point a picture, then you can upload an avatar successful (change Events + file reader), asynchronous read the file (IO operation), use onload, wait until loaded show,
      2. Data entry is complete, binding to the button click event, send ajaxrequests, both ordinary key, another file, consider the use of formdataobjects, use serializerArray, need to manually add the file object
    3. rear end:
      1. Correct logic: registration function, resulting form object that defines the empty dictionary (ajax request) to determine whether legitimate, ** break up data, key fields must be the same as the name of the file to determine the object's head to see if there is, then create users, update the database .
      2. Error Logic: Save dictionary error message, you can see the name tag, hand stitching by ajax callback function to get a string of error messages, rendering it with has-error.
  3. Log function
    1. Routing view function, the front page
    2. front end:
      1. User name, password, authentication code
      2. Image verification code, click on the picture is not the same
      3. Binding login button click event, send a ajaxrequest (user name, password, authentication code)
      4. Callback function, information dictionary judge, will render an error message
    3. rear end
      1. Authentication code, a single view function, the random codes stored in the session, used for view function
      2. To get a user name, password, authentication code, to determine the verification code, in determining whether the correct user name and password, log on success on the preservation of the state, to determine some of the error messages, saved to the msg
  4. Home Information Display
    1. Routing, and view the front page
    2. front end:
      1. Navigation, on Bootstrap style, plus the left and right (2-8-2) of the intermediate layout, plus the left and right panels,
      2. Successful login, the user name and show more operations are not logged in, log in to show registration, plus a judge, and then the two parts separately into them, the login, registration and cancellation of bindings were related Url
      3. Dynamic effects in jsthe plug-in, add a modal box, change the password used to set the interface, the contents written in the modal box, wrong or rendering error messages, click the submit button binding event, send ajaxa request to send the note data, as well as jump to, set_password page,csrf
    3. rear end:
      1. home page, directly back to home page
      2. logout page (whether a user is logged in, use login_required, adding configuration settings), the write-off directly with built-in functions,
      3. set_password page, login authentication first, dictionaries ajax, postverify, verify whether the same password twice, old password, it is stored properly update the database dictionary to add a urlfield to jump to after a successful login page, then the error information is added the dictionary, return to the front
  5. Admin: The adminregistration of each model in the table, you can achieve CRUD four pages, add articles, articles classification, tag, and then enter the data, pay attention to the corresponding association in the user table blog
  6. Home show list of articles:
    1. All back-end home to get a list of articles, plus a paging component, then write in the home paging logic functions
    2. The front end of the article carried by the media a list of object information display, use Bootstrap, article generation cycle, article titles, avatars, profiles, release date, thumbs, Reviews
  7. Home users avatar
    1. It directly to the front end of the corresponding avatar field, and also need to upload the file into a special resource folder, configure settings related to the path, but also need to expose the folder, the fixed wording, in the route add a similar group known url, and then spell the relevant path at the front end,
  8. Personal site
    1. Before adding a 404 page, picture on the local, to prevent anti-hotlinking images
    2. rear end:
      1. Log in, then get all articles
# 表中的__str__方法

'''
用于在admin后台页面中,重写print方法,让打印结果更可视化,比如写一个 __str__ ,在后台中返回名字,不加的话是一个对象:Blog object、Category object等
'''
def __str__(self):
    return self.username




# 用户头像没显示出来

'''
错误原因是没有在admin 中把用户和个人站点表绑定起来。其实在使用跨表查询、子查询等拿到的字段,遇到问题,应该首先去admin后台中看看,是否把用户和个人站点绑定起来了。
'''

Guess you like

Origin www.cnblogs.com/michealjy/p/11823225.html
Recommended