Django practice (3): Django can also have Scaffold

Source: Internet
Author: User

Rails has a useless "magic" function called scaffold. The crud interface can be automatically generated based on the model.

It is useless because the rails developer David said that scaffold is not an application.ProgramDevelopment purpose. It only provides support when we build an application. When you design how the product list works, you rely on the "Bracket" and "generator" to generate, update, and delete actions. Then, you must replace the action generated by the generator when retaining this "action. Sometimes when you need a quick interface, and you don't care about the ugly interface, the "Bracket" is enough. Don't expect scaffold to meet all your program's needs ".
It's amazing because you don't know how it works in rails. I will only tell you one sentence: the Convention takes precedence over the configuration. As long as the name is XXX, it will be xxx. I think rails is a great framework.

There is no such useless thing in Django's world. However, if you have to, you can easily create such a set. Next we will introduce a "plug-in" in the project ". As mentioned above, apps can be easily reused among multiple projects. We want to introduce a third-party app, which can be used with simple configuration without modification.

This app is called Django-groundwork. Instead of implementing specific functions, it extends the manage. py command so that you can generate someCode/File.

Download the Django-groundwork code:

$ Git clone https://github.com/madhusudancs/django-groundwork.git

$ Ls Django-groundwork

Authors license readme. rst Django-groundwork

SetTheCopy the Django-groundwork folder to the project folder and add the app to settings. py:

 

Installed_apps = (  #  'Django. contrib. auth ',      #  'Django. contrib. contenttypes ',      #  'Django. contrib. session ',      #  'Django. contrib. Sites ',     #  'Django. contrib. Messages ',      #  'Django. contrib. staticfiles ',          #  Uncomment the next line to enable the admin:      #  'Django. contrib. admin ',      #  Uncomment the next line to enable admin documentation:      #  'Django. contrib. admindocs ',       '  Depot. depotapp  ' ,  '  Django-groundwork  '  ,) 

 

The installation is complete. (If you have any trouble, you can also download the source code package included in this article)

 

After installation, you can use $ Python manage. py help to see that a groundwork is added to the available commands listed. Its syntax is:

$ Python manage. py groundwork appname modelname1 modelname2

Next, use this app to generate scaffold for the product:

$ Python manage. py groundwork depotapp product generates the so-called scaffold.

Run the Development Server (Python manage. py runserver) to access the following address:

Http: // localhost: 8000/depotapp/product/LIST/access the product list and link it to the create, edit, view, and other interfaces.

 

You can downloadSource code: Http://download.csdn.net/detail/thinkinside/4035662

 

 

 

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.