Django-Vue3-Admin

repository·master·Indexed 21 days ago

https://github.com/huge-dream/django-vue3-admin

An open-source rapid development platform for enterprise-grade administration. It features a decoupled architecture with a Django and Django REST Framework backend and a Vue3, TypeScript, and Vite frontend. The platform implements a Role-Based Access Control (RBAC) model with granular permissions reaching the column level. It includes tools like dvadmin3-build for packaging the project into executables for Windows and macOS, as well as Docker support for containerized deployment.

Tokens
32.3K
Snippets
91
Records
127
Agent score
74%

What's inside django-vue3-admin

  1. Overview of Django-Vue3-Admin

    master

    Django-Vue3-Admin is an open-source rapid development platform based on the RBAC (Role-Based Access Control) model. It features fine-grained permission control down to the column level.

    Architecture:

    • Backend: Python with Django and Django REST Framework (DRF).
    • Frontend: Vue 3, Composition API, TypeScript, Vite, Pinia, and Element Plus.
    • Authentication: Uses Django REST Framework SimpleJWT for multi-terminal support.
    • Permissions: Supports dynamic permission menus and granular column-level access control.
  2. Core Features of Django-Vue3-Admin

    master

    Django-Vue3-Admin is a rapid development platform featuring a frontend-backend separation architecture and an RBAC (Role-Based Access Control) model with column-level granularity.

    Key capabilities include:

    • Menu Management: Configure system menus, operation permissions, button permission flags, and backend interface permissions.
    • Department & Role Management: Manage organizational structures and assign menu/data permissions based on departments.
    • Granular Permission Control: Supports both Button Permission Control (authorizing specific interface/button actions) and Field Column Permission Control (authorizing the display of specific columns on a page).
    • User & API Management: Manage system operators and configure an API Whitelist for interfaces that bypass permission verification.
    • System Utilities: Includes Dictionary Management, Region Management (provinces/cities), File Management, and Operation Logs.
  3. Use dvadmin3-build to package django-vue3-admin

    master

    Overview

    dvadmin3-build is a packaging tool designed to compile the django-vue3-admin project into executable files (e.g., .exe for Windows) or installation packages (e.g., .dmg for macOS).

    Key Features:

    • Easy Deployment: Packages the entire project into a single executable or installer, eliminating the need for manual environment configuration on target machines.
    • Code Encryption: Supports encrypting source code into binary format to protect intellectual property.
    • One-click Startup: The packaged application can be launched via a simple double-click.
    • Cross-platform Support: Currently supports Windows and macOS.
    • Tray Minimization: Supports minimizing the application to the system tray.
  4. Built-in Features of Django-Vue3-Admin

    master

    The platform includes several core management modules:

    • Menu Management: Configure system menus, operation permissions, button permission identifiers, and backend interface permissions.
    • Department Management: Configure organizational structures (companies, departments, roles).
    • Role Management: Assign menu permissions, data permissions, and define data scope by department.
    • Button Permission Control: Authorize specific buttons and interfaces, allowing data scope authorization for every interface.
    • Field/Column Permission Control: Control the visibility of specific fields/columns on pages.
    • User Management: Manage system operators and user configurations.
    • Interface Whitelist: Configure interfaces that do not require permission validation.
    • Dictionary Management: Maintain fixed data used throughout the system.
    • Region Management: Manage province, city, and county areas.
    • Attachment Management: Centralized management of files and images.
    • Operation Logs: Record and query normal and abnormal system operations.
    • Plugin Market: Access applications and plugins developed for the framework.
  5. Prerequisites for Django-Vue3-Admin

    master

    Before starting the project, ensure your environment meets the following requirements:

    • Python: >= 3.11.0 (Minimum version 3.9+ supported)
    • Node.js: >= 16.0
    • MySQL: >= 8.0 (Optional; default is SQLite3, which supports 5.7+; version 8.0 is recommended)
    • Redis: Optional (latest version recommended)
  6. Deploy using Docker Compose

    master

    You can use docker-compose to orchestrate the entire stack.

    Initial Setup: After running docker-compose up -d, you must execute the initialization commands inside the backend container to set up migrations and data.

    Default URLs:

    • Frontend: http://127.0.0.1:8080
    • Backend API: http://127.0.0.1:8080/api

    Note: Replace 127.0.0.1 with your server's public IP if deploying remotely.

    Default Credentials:

    • Account: superadmin
    • Password: admin123456
    # Start services
    docker-compose up -d
    
    # Initialize backend data (first execution only)
    docker exec -ti dvadmin3-django bash
    python manage.py makemigrations 
    python manage.py migrate
    python manage.py init_area
    python manage.py init
    exit
    
    # Management commands
    docker-compose stop
    docker-compose down
    docker-compose restart
    docker-compose up -d --build
  7. Setup and Run the Backend

    master

    The backend uses Django and Django REST Framework. Follow these steps to configure and run the server:

    1. Navigate to the backend directory.
    2. Create your environment configuration by copying ./conf/env.example.py to ./conf/env.py.
    3. Configure your database information in env.py (MySQL 8.0 with utf8mb4 character set is recommended).
    4. Install Python dependencies via pip.
    5. Run database migrations.
    6. Initialize system data and regional data (provinces, cities, etc.).
    7. Start the server using manage.py runserver or uvicorn.

    Swagger API Documentation:

    • Default URL: http://localhost:8080 (configurable via the config file)
    • Default Credentials: superadmin / admin123456
    # 1. enter code dir
    cd backend
    
    # 2. copy ./conf/env.example.py to ./conf dir, rename as env.py
    # 3. in env.py configure database information
    
    # 4. install pip dependence
    pip3 install -r requirements.txt
    
    # 5. Execute the migration command
    python3 manage.py makemigrations
    python3 manage.py migrate
    
    # 6. Initialization data
    python3 manage.py init
    
    # 7. Initialize provincial, municipal and county data
    python3 manage.py init_area
    
    # 8. start backend
    python3 manage.py runserver 0.0.0.0:8000
    
    # OR using uvicorn
    uvicorn application.asgi:application --port 8000 --host 0.0.0.0 --workers 8
  8. Build and push Web base images

    master

    To create a base Web build image and upload it to the Aliyun registry, use the following commands. This is typically used for creating optimized base layers for the frontend.

    # Build to local
    docker build -f ./docker_env/web/DockerfileBuild -t registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-web:16.19-alpine .
    
    # Push to Aliyun registry
    docker push registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-web:16.19-alpine
  9. Build individual service containers

    master

    You can build standalone Docker images for the Web, Django, or Celery services using their respective Dockerfiles.

    # Build Frontend
    docker build -f ./docker_env/web/Dockerfile -t dvadmin-pro-web .
    
    # Build Backend
    docker build -f ./docker_env/django/Dockerfile -t dvadmin-pro-django .
    
    # Build Celery
    docker build -f ./docker_env/celery/Dockerfile -t dvadmin-pro-celery .