day 68 bbs project knowledge

admin background management (******)
can generate a registered model table CRUD at least four pages
http://127.0.0.1:8000/admin/app01/userinfo/ view the user
http: //127.0. 0.1: 8000 / admin / app01 /edit user
http://127.0.0.1:8000/admin/app01/userinfo/add/ add users
http://127.0.0.1:8000/admin/app01/ userinfo / 2 / delete / remove users

http://127.0.0.1:8000/admin/app01/blog/ view personal sites
http://127.0.0.1:8000/admin/app01/blog/1/change/ edit personal sites
http://127.0.0.1:8000/admin/app01/blog/add/ add a personal site
http://127.0.0.1:8000/admin/app01/blog/2/delete/ delete personal site



user avatar rendering
the default Web site static resource files on static default folder
users to upload static resource files should be stored separately in a certain folder

# specified users to upload static files all the resources into one specified folder under
MEDIA_ROOT = os.path. the Join (base_dir, 'Media')

from Import serve django.views.static
Import the BBS Settings from
# exposed to the outside of the rear end of the file resource
url (r '^ media / ( P <path> *)?.', serve, { 'document_root': settings.MEDIA_ROOT})


image anti-theft chain
when the request detects whether the source address of the current request comes from your own site
refer on the request header inside the data used to indicate which site you belong to

if you want to use the most simple and crude way is first downloaded to the local (automatic crawlers write down)




Date of cutting
date create_time month The Archive Content
1 111 2019-11-1 2019-11 
1 111 2019-11-25 2019-11
1 111 2019-11-10 2019-11
1 111 2019-10-1 2019-10

# documents provided by the official
from django.db.models.functions Import TruncMonth
Article.objects
.annotate (= month the TruncMonth ( 'create_time'))      # Truncate to month the List and the Add to the SELECT
.values ( 'month the')    # By month the Group
. Annotate (the Count = C ( 'ID'))    # of the Select The COUNT The GROUPING
.values ( 'month The', 'C')   # (Might be redundant, have not tested) select month and count

Note: When you're writing the url re-visit found no hit, then you should go see if urls.py was intercepted in front of the most effortless way url solution is to swap the position of



a custom inclusion_tag
when an area on a page needs to be used frequently and need to pass parameters to be able to render 
then you can consider using inclusion_tag

inclusion_tag custom steps:       

# With custom filters and labels are the same
1. Create a folder name must pay templatetags
2. Create a py file any
written documents fixation 3.py two lines of code
from django.template Import Library
the Register = Library ()

# works     

Call a procedure similar to the function
you use inclusion_tag they can for their mass participation, it will pass parameters to a html page
the page will use the parameters passed to it to render the page and then call on the rendered page where inclusion_tag





























Guess you like

Origin www.cnblogs.com/wwei4332/p/11799572.html