search
HomeBackend DevelopmentPython TutorialPython server programming: using django-jet for background management

In the modern Internet era, server programming is an essential skill. Among them, Python has become one of the most widely used programming languages, and there are more and more server programming tools for Python. One of the recommended tools is django-jet.

django-jet is a modern and concise style background management interface framework based on the Django framework and is widely used in Python server-side development. Django-jet provides a unified backend management interface, including routing, forms, lists, search, filtering, paging, uploading and other functions, which is very suitable for internal information management of enterprises.

So, how to use django-jet for background management? After actual testing, we will introduce it to you in detail below.

First, you need to install django-jet. It can be installed from the command line via pip: pip install django-jet. In addition, you also need to add "jet" and "jet.dashboard" to INSTALLED_APPS in the settings.py file.

Next, routing configuration needs to be done in the urls.py file. Specifically:

(1) Import jet and admin in the DJANGO_PROJECT/urls.py file.

from django.urls import path, include
from django.contrib import admin
from jet.dashboard.dashboard_modules import google_analytics_views
from jet.dashboard.dashboard_modules import yandex_metrika_views
from jet.dashboard.dashboard_modules import memcache_views
from jet.dashboard.dashboard_modules import generator_views
import jet.urls

urlpatterns = [
    path('django_admin/', admin.site.urls),
    path('jet/', include('jet.urls', 'jet')),
    path('jet/dashboard/', include('jet.dashboard.urls', 'jet-dashboard')),
]

(2) Modify the urls.py file of the application and link to the above configuration.

from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('jet/', include('jet.urls', 'jet')),
    path('jet/dashboard/', include('jet.dashboard.urls', 'jet-dashboard')),
]

(3) Add some necessary configuration items in the settings.py file.

INSTALLED_APPS = [
    # ... some other apps
    'jet',
    'jet.dashboard',
    'django.contrib.admin',
]

JET_DEFAULT_THEME = 'default'
JET_SIDE_MENU_COMPACT = True
JET_CHANGE_FORM_SIBLING_LINKS = True
JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'

TEMPLATES = [
    {
        # ... some other settings
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
            os.path.join(BASE_DIR, 'templates/jet'),
            os.path.join(BASE_DIR, 'templates/jet.dashboard'),
        ],
        'APP_DIRS': True,
        # ... some other settings
    },
]

What needs to be noted here is:

a. JET_DEFAULT_THEME: Set the theme color of the django-jet background management interface, which can be set to "default", "green", "purple", etc.

b. JET_SIDE_MENU_COMPACT: Set whether the side menu should be compressed.

c. JET_CHANGE_FORM_SIBLING_LINKS: Set whether to enable django-jet's changing links.

d. JET_INDEX_DASHBOARD: Set the default django-jet background management interface.

(4) Configure dashboard.CustomIndexDashboard

First, add a new class in the application's models.py, then add a method in this class, and register it with a decorator, as follows Display:

from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
from django.utils.translation import ugettext_lazy as _

class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.available_children.append(
            AppIndexDashboard(
                _('Applications'),
                column=1,
                children=[{
                    'app_label': app_label
                } for app_label in [
                    'auth', 'personal', 'hello_django_starter'
                ]],
                deletable=False,
            ),
        )

Among them, the init_with_context method is used to initialize the background management interface, and you can adjust the page information by yourself. Here we simply set up 3 columns of content, including applications, tasks, subscription management, etc.

Finally, we need to run python manage.py runserver as before to start the web server, and enter http://127.0.0.1:8000/jet/ in the browser to see the implemented background Management interface.

To summarize, it is very simple to use django-jet to build a backend management interface. It only takes a few steps to complete and is one of the recommended tools for Python server programming. If you need to use the backend management interface when developing enterprise information management systems, data visualization and other applications, here is a feasible solution for your reference.

The above is the detailed content of Python server programming: using django-jet for background management. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Learning Python: Is 2 Hours of Daily Study Sufficient?Learning Python: Is 2 Hours of Daily Study Sufficient?Apr 18, 2025 am 12:22 AM

Is it enough to learn Python for two hours a day? It depends on your goals and learning methods. 1) Develop a clear learning plan, 2) Select appropriate learning resources and methods, 3) Practice and review and consolidate hands-on practice and review and consolidate, and you can gradually master the basic knowledge and advanced functions of Python during this period.

Python for Web Development: Key ApplicationsPython for Web Development: Key ApplicationsApr 18, 2025 am 12:20 AM

Key applications of Python in web development include the use of Django and Flask frameworks, API development, data analysis and visualization, machine learning and AI, and performance optimization. 1. Django and Flask framework: Django is suitable for rapid development of complex applications, and Flask is suitable for small or highly customized projects. 2. API development: Use Flask or DjangoRESTFramework to build RESTfulAPI. 3. Data analysis and visualization: Use Python to process data and display it through the web interface. 4. Machine Learning and AI: Python is used to build intelligent web applications. 5. Performance optimization: optimized through asynchronous programming, caching and code

Python vs. C  : Exploring Performance and EfficiencyPython vs. C : Exploring Performance and EfficiencyApr 18, 2025 am 12:20 AM

Python is better than C in development efficiency, but C is higher in execution performance. 1. Python's concise syntax and rich libraries improve development efficiency. 2.C's compilation-type characteristics and hardware control improve execution performance. When making a choice, you need to weigh the development speed and execution efficiency based on project needs.

Python in Action: Real-World ExamplesPython in Action: Real-World ExamplesApr 18, 2025 am 12:18 AM

Python's real-world applications include data analytics, web development, artificial intelligence and automation. 1) In data analysis, Python uses Pandas and Matplotlib to process and visualize data. 2) In web development, Django and Flask frameworks simplify the creation of web applications. 3) In the field of artificial intelligence, TensorFlow and PyTorch are used to build and train models. 4) In terms of automation, Python scripts can be used for tasks such as copying files.

Python's Main Uses: A Comprehensive OverviewPython's Main Uses: A Comprehensive OverviewApr 18, 2025 am 12:18 AM

Python is widely used in data science, web development and automation scripting fields. 1) In data science, Python simplifies data processing and analysis through libraries such as NumPy and Pandas. 2) In web development, the Django and Flask frameworks enable developers to quickly build applications. 3) In automated scripts, Python's simplicity and standard library make it ideal.

The Main Purpose of Python: Flexibility and Ease of UseThe Main Purpose of Python: Flexibility and Ease of UseApr 17, 2025 am 12:14 AM

Python's flexibility is reflected in multi-paradigm support and dynamic type systems, while ease of use comes from a simple syntax and rich standard library. 1. Flexibility: Supports object-oriented, functional and procedural programming, and dynamic type systems improve development efficiency. 2. Ease of use: The grammar is close to natural language, the standard library covers a wide range of functions, and simplifies the development process.

Python: The Power of Versatile ProgrammingPython: The Power of Versatile ProgrammingApr 17, 2025 am 12:09 AM

Python is highly favored for its simplicity and power, suitable for all needs from beginners to advanced developers. Its versatility is reflected in: 1) Easy to learn and use, simple syntax; 2) Rich libraries and frameworks, such as NumPy, Pandas, etc.; 3) Cross-platform support, which can be run on a variety of operating systems; 4) Suitable for scripting and automation tasks to improve work efficiency.

Learning Python in 2 Hours a Day: A Practical GuideLearning Python in 2 Hours a Day: A Practical GuideApr 17, 2025 am 12:05 AM

Yes, learn Python in two hours a day. 1. Develop a reasonable study plan, 2. Select the right learning resources, 3. Consolidate the knowledge learned through practice. These steps can help you master Python in a short time.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use