In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the background management function of Django". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the background management function of Django.
Create a background administrator account (demosite) E:\ PycharmProjects\ demosite > python manage.py createsuperuserUsername: adminEmail address: alexnn@qq.comPassword:Password (again): Superuser created successfully.
Enter http://127.0.0.1:8000/admin in the browser to log in to the background management interface
Add the established data model to the background management interface for management.
Write the admin.py file under the application directory, that is, you can register the data model class you created with admin.
From django.contrib import admin# Register your models here.from .models import BlogArticles # introduces BlogArticles classes into the current environment admin.site.register (BlogArticles) # registers model classes with admin
After refreshing the page, it is shown in the figure:
Manage data records for the data model
Click the corresponding data model class on the management page to view a list of all records in the data model
If you feel that the function of the management page is not enough, you can continue to write admin.py files to add management functions.
From django.contrib import admin# Register your models here.from .models import BlogArticlesclass BlogArticlesAdmin (admin.ModelAdmin): list_display = ("title", "author", "publish") list_filter = ("publish", "author") search_fields = ("title", "body") raw_id_fields = ("author",) date_hierarchy = "publish" ordering = ['- publish', 'author'] admin.site.register (BlogArticles, BlogArticlesAdmin)
The effect after refreshing the page is as follows:
At this point, I believe you have a deeper understanding of "how to use the background management function of Django". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.