Talking about the calling method of view to database in Django

  • 2021-07-22 10:41:00
  • OfStack

question:

In Django, it is very hidden to call the database, and it is difficult to find the part of obtaining the database content in the splicing and inheritance of various complex modules

Come on, start trying to understand 1.

First of all, the table in the database corresponds to every class in model, and the variables in the class correspond to the attributes of the table. Usually, the attribute name is the variable name. One special thing is ForeignKey, which represents the constraint key associated with other tables, that is, the constraint key in SQL, which is usually associated with the primary key primary key in other tables.

Understand that model is the data table that we define, the next thing will be more simple, we all know that the information of data in the web page is filtered and displayed by Django view, so in fact, in veiw, the output work after a series of filters for the data is just

django-sekizai:

Sekizai means "blocks" in Japanese, and that 's what this app app s With With With With With django get rendered get rendered different different places different places blocks blocks blocks blocks blocks for css and javascript. Your can now-templates can now define css and and and be and the the the the and and and and you should, Also you should should Also 111EN any duplicate content in a single block.

sekizai means Block in Japanese. In fact, its function is similar to Block, but it has a brand-new look based on Block. Django-sekizai is mostly used in css and js. Through sekizai, you can separate the block you need to define from the contents you need to fill in. You can add css (placed at the top when importing) and js (placed at the bottom when importing) written in your sub-template to realize the functions of css and js. And it will ignore the complex content in a simple Block.

Personal understanding: The actual function of sekizai is to manage js and css used in {% block%}, and the sekizai community uses the rule of putting css at the top and js at the bottom, which not only realizes the code neatness, but also realizes the function of separating the code in {% block%} from the complicated css and js codes.


Related articles: