If you have installed Python applications, these functions are available in addition to the standard library, there are also many other high-quality libraries, such as wxPython, Twisted, and Python graphics libraries, I hope you will be able to study.
Freemarker is the most complex and powerful. Supporting jsp tag embedding allows us to reuse many existing components, I have also described this in detail in my previous article (join hands to see the combination of freemarker and displaytag ). Because of understanding, you can have the right to speak. django's template can be said to have been born for Internet applications. Its concise and fast development features are quite appealing.
Jsp aside, whether it is ruby, c ++, or Python applications, templates are used in their web frameworks. There are also many templates in java. We are most familiar with freemarker and velocity. This reflects a pattern in web development from one aspect, that is, our view is basically generated based on templates.
Jsp is the product of the times. It was created in a chaotic and backward age, but it is strange that there are so many people holding it. Django has two forms: one is to define the form class, and the other is to define the automatic form class through the model we define. Ahuaxuan only provides a small example of information publishing.
Therefore, you cannot fully understand or understand all the details of form in django, I do feel that django's practice of creating a form from a model is quite limited. In many cases, the data in the model is not from the page. In this case, after the form object is constructed, ahuaxuan has not found the method to modify the median of the form.
The custom form class is also troublesome, that is, to write your own model. This is different from our previous practice. Here, form represents the value object in java, and model is the domain object. In our ssh framework, we usually inherit the value object from our domain object. Although a bunch of people have raised objections, they say they want to separate the two objects.
Because they are at different levels, but from practical experience, we can see that there is nothing wrong with doing so. However, the separation of custom form and model in django may be in line with the psychology of some people. However, Custom forms are also commendable. In form, we can customize verification rules. At the same time, we can directly generate content on the page based on the form object.
However, this is also troublesome, that is, it is troublesome to change the style. However, in general, django's form is quite characteristic, and it brings us convenience to a certain extent. Django's url-based forwarding is based on regular expressions. Some people are good, some are bad, and I am one of them. Url forwarding should be very clear and bright.
However, after using this regular expression to match something, I am depressed, so I can only go back to the distant past to bypass this stuff. I don't need to always do it. In terms of form, the two are surprisingly similar, such as input parameters. We know that python is an object-oriented language, but in fact it also supports function programming, if def is defined inside the class.
So it is the object method. Otherwise, we can think of it as function programming. Let's see that all the things in our views are functions, and views are actually a module, this module can be considered as the action in struts1.x, while the function in views can be considered as the method in action. They are distant relatives.
The admin feature of a Python application is known as the killer feature of django. This is an appropriate and exaggerated one. From the example I have made, when I do a website, I basically only need to pay attention to the front-end page display.
The background functions are basically automatically available. For example, I used a second-hand information publishing platform, category is a second-hand information type, and there is also an information class, the relationship with category is many-to-one, so in the background, the crud of category and information is automatically produced. Because category itself is a self-Association, when you add category in admin, admin will follow the definition of my model.
A parentCategory is automatically required. On the add information page, admin requires me to select a category to create an information. In java, these tasks must be completed by yourself. Of course, there are also many tools that can automatically generate crud.
However, these open-source tools are basically for a single model, and the generated code must be greatly modified to truly run the function, the most important thing is that the management of associations cannot be automatically generated. Of course, I have also seen some companies make database-driven code producers.
It can generate complete and available code and pages, as well as link processing. However, due to the differences in language features, during development, we still need to constantly restart the server to display results, although technically, it is not difficult to implement this function for ssh, it will take a lot of time. If it takes a lot of time, few companies will contribute to it.
Therefore, I personally think that django is doing very well in this function, especially this function can save developers a lot of time. In some cases, the project can be executed in two lines. The user enters data through admin and the programmer develops the foreground. After the foreground function is completed, the data is also available and the test is available. This feature is especially important for small projects that require rapid development, because django is generated based on this scenario.
Of course, sometimes the background is not so simple, but fortunately, admin provides the extended function. We can write the extended code ourselves and then integrate it into admin, however, apart from the admin template, we cannot change any admin code.
However, I often wonder if admin supports the function of automatic code generation. We can modify the background functions at will. Otherwise, we need to write our own code, it is not as convenient to expand the generated code. To use admin.
You must open the permission module of django. Here is a brief introduction to the permission module. django comes with a permission module. The model in this permission module is no longer familiar to anyone who is familiar with the permission module. user, group, permission, user, and group.
Python applications and permission are many-to-many. In acegi, we usually define user, role, and resource as follows, which is the same as the permissions in django, however, in django, the default permission granularity is very coarse, which is based on the model. If we want more detailed permission modules, we need to expand them ourselves.
- Introduction to Python system files
- How to correctly use Python Functions
- Detailed introduction and analysis of Python build tools
- Advantages of Python in PythonAndroid
- How to Use the Python module to parse the configuration file?