Creating a database view in [Django]

Source: Internet
Author: User

Create a database view in Django

There is no interface for creating views in Django, and some manual changes are required if you want to create a view. The Django version >1.5 used here, the database used for MySQL

The first step

Establish a view, such as the name of a view called User_info

Step Two

This is written in model:

class MyModel(models.Model):    ...    class Meta:         managed = False         db_table = "user_info"

This allows the view to be transformed into an ORM object.

Ref:creating Django Model for existing Database/sql view?

Django Models Documentation

This article is derived from "Orangleliu notebook " Blog, be sure to keep this source http://blog.csdn.net/orangleliu/article/details/39381863


Creating a database view in [Django]

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.