Skip to main content

资源数据模型

Project description

xy_django_app_resource

说明

通用资源数据模型.

源码仓库

安装

# bash
pip install xy_django_app_resource

使用

1. 直接引入
  • 1. 设置全局配置

在Django项目中的settings.py文件中加入如下配置 例如: settings.py

# settings.py

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "xy_django_app_resource",
    "Demo",
    "Media",
]
  • 2. 运行项目
xy_web_server -w django makemigrations
xy_web_server -w django migrate
# 同步数据表
xy_web_server -w django start
# 启动工程后访问 http://127.0.0.1:8401/admin 验证资源管理系统
2. 自定义
  • 1. 创建Resource模块

操作 样例工程

# bash
xy_web_server -w django startapp Resource
# Resource 模块创建在 source/Runner/Admin/Resource 
  • 2. 设置全局配置

在Django项目中的settings.py文件中加入如下配置 例如: settings.py

# settings.py

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "Demo",
    "Media",
    "Resource",
]
# models.py

import uuid
from django.utils.translation import gettext_lazy as _
from django.db import models
from xy_django_app_resource.abstracts import MAImage


class MImage(MAImage):
    id = models.BigAutoField(primary_key=True)
    create_at = models.DateTimeField(
        verbose_name=_("创建时间"),
        auto_now_add=True,
        editable=True,
    )
    update_at = models.DateTimeField(
        verbose_name=_("更新时间"),
        auto_now_add=True,
        editable=True,
    )
    identifier = models.UUIDField(
        verbose_name=_("唯一标识"),
        default=uuid.uuid4,
        editable=True,
        unique=True,
        null=True,
    )
    is_active = models.BooleanField(
        verbose_name=_("是否启用"),
        null=True,
        blank=True,
        default=False,
    )

    class Meta:
        verbose_name = _("图片")
        verbose_name_plural = _("图片")
        app_label = "Resource"

    def __str__(self):
        return f"{self.id}. {self.identifier}"
# admin.py
from django.contrib import admin
from .models import MImage

@admin.register(MImage)
class AImage(admin.ModelAdmin):
    list_per_page = 20
    filter_horizontal = []
    list_display_links = [
        "id",
        "identifier",
        "update_at",
        "create_at",
    ]
    list_display = [
        "id",
        "identifier",
        "update_at",
        "create_at",
    ]
    search_fields = list_display
    autocomplete_fields = [
        # "id",
        # "communicate_at",
        # "identifier",
    ]
  • 5. 运行项目
xy_web_server -w django makemigrations
xy_web_server -w django migrate
# 同步数据表
xy_web_server -w django start
# 启动工程后访问 http://127.0.0.1:8401/admin 验证资源管理系统
运行 样例工程

样例工程具体使用方式请移步 xy_web_server.git 下列仓库

许可证

xy_django_app_resource 根据 <木兰宽松许可证, 第2版> 获得许可。有关详细信息,请参阅 LICENSE 文件。

捐赠

如果小伙伴们觉得这些工具还不错的话,能否请咱喝一杯咖啡呢?

Pay-Total

联系方式

微信: yuyangiit
邮箱: yuyangit.0515@qq.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xy_django_app_resource-1.0.3.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

xy_django_app_resource-1.0.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file xy_django_app_resource-1.0.3.tar.gz.

File metadata

File hashes

Hashes for xy_django_app_resource-1.0.3.tar.gz
Algorithm Hash digest
SHA256 195e64659a138d9ba0aeecf2eb2fd513a7258f2abf7e08874908348272a73458
MD5 0bb8bf66e778592951f0f8a1d2e5efd0
BLAKE2b-256 cae0bccb0143aa604a4e516fcd1579fb3bf8da201c8c84f557aa19a8834fe47e

See more details on using hashes here.

File details

Details for the file xy_django_app_resource-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for xy_django_app_resource-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0a1feea71334c786da68c1d75b9bac3773ba6abb79e0b1bea88e79e89147bd38
MD5 aeab36b3f2c63927a58e456a145f9dd0
BLAKE2b-256 e48527f6574948571f29d982a8ffda162155b0f27643b2d9f9d826a207a2403b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page