Describes the Python programming language.

Source: Internet
Author: User
Tags django tutorial

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 and the like, because people who don't know hibernate always say that hibernate is not faster than ibatis. In fact, I am the most annoying, and 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:

 
 
  1. class Category(models.Model):     
  2.     id = models.AutoField('id', primary_key=True)     
  3.     name = models.CharField(maxlength=50)     
  4.     code = models.CharField(maxlength=50)     
  5.     parentCategory = models.ForeignKey('self', 'id', null=True)     
  6.     enable = models.BooleanField()     
  7.          
  8.     def __str__(self):     
  9.         return self.name     
  10.          
  11.     class Admin:     
  12.         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.

Related Article

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.