Describes the Python programming language.

Source: Internet
Author: User
Tags django tutorial
Write the Python programming language extension module (dynamic link library) in C ++ connector and call the extension function developed by C ++ in the Python program. Just a few days ago, I have nothing to do with django in the Python programming language. as experts and scholars have said, to be a successful developer, you must first master another language, so I chose the Python programming language.

Over the past few days, I have found that other languages and their frameworks are indeed quite different. Next, I will summarize what I have seen over the past few days. This article is not a django tutorial. it is about ahuaxuan's understanding of django. it may be somewhat immature. I hope you will not cherish the bricks in your hands.

If someone asks me what I like most about django in the Python programming language, I will not hesitate to tell you that it is django's orm, this idea comes from my "dissatisfaction" with hibernate over a long period of time, although from a rational point of view.

Hibernate is doing very well, because it is not only for Internet connection, its main market should still be in enterprise applications, but it is not impossible to use it on the Internet. However, most people will choose ibatis or the like, because people who do not know hibernate always say that hibernate is not as fast as ibatis (in fact, I am the most annoying, one-sided comparison is meaningless ).

It is exactly what hibernate aims to create an all-around and all-powerful orm framework in the java World. Therefore, its learning curve and complexity of use are increasingly increasing. It is not easy to fully master hibernate. (don't tell me that you will click crud. if you know something about lazy load, you will have mastered hibernate ).

A detailed discussion on a wide range of Python Enterprise Applications

A list of clear and transparent Python applications

How to innovate Python virtual machine threads

Research and discussion on Python main thread issues

Study on Python thread operations


Let's look back at django's orm. if we want to clarify hibernate, we need a 800-page book, so we need to clarify django's orm, the 200 page is enough (in fact, its official documentation only looks like a dozen pages ). Here is an example I am working on.

Here is a self-associated object (in fact, django's orm is based on model, which is different from ror. Someone told me that ror is a database driver). This object has a parent object. Generally, our menu is defined as such an object. such a menu can be expanded infinitely:

Class Category (models. model): id = models. autoField ('id', primary_key = True) name = models. charField (maxlength = 50) code = models. charField (maxlength = 50) parentCategory = models. foreignKey ('self ', 'id', null = True) enable = models. booleanField () def _ str _ (self): return self. name class Admin: list_display = ('id', 'name', 'Code', 'parentcategory ')

The Admin defined in the Python programming language serves the Admin module of django. The defined domain Model only requires the code. models. Model is the parent object. All model objects must inherit this object. this object provides many common database methods, but is not based on SQL or object, just like Criteria. The following lists common methods for querying Category.

Of course, django's orm provides a lot of frequently-used functions. I will not give them one by one here. Note that here I am talking about a lot of frequently-used functions, for the complex hibing policies in hibenate. I didn't see it in django.

However, I'm glad that I didn't find this function in django, because django is positioned as a fast Internet development. it doesn't need to pay too much attention to things that rarely appear in this field, the advantage of this is that the learning curve is reduced and the development efficiency is improved.

The above is the description of the Python programming language. For more articles, please follow the PHP Chinese network (www.php1.cn )!

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.