37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy
|
|
from uuid6 import uuid8
|
|
|
|
from wechat_数据库.用户数据库.小程序登陆用户 import models_app_name, weiuser
|
|
from wechat_数据库.雪花算法.雪花算法工具 import generator
|
|
|
|
|
|
class weiuser微信用户地址(models.Model):
|
|
"""城市信息表"""
|
|
objects = models.Manager() #
|
|
|
|
class choicesAddress(models.TextChoices):
|
|
是默认地址 = "是默认地址", gettext_lazy("是默认地址")
|
|
不是默认地址 = "不是默认地址", gettext_lazy("不是默认地址")
|
|
|
|
# idKey = models.CharField(primary_key=True, default=generator.generate_str, )
|
|
id_主键_配送地址 = models.UUIDField(primary_key=True, default=uuid8)
|
|
id_str = models.CharField(max_length=128, default=generator.generate_str)
|
|
mini_openid = models.CharField()
|
|
mini_unionid = models.CharField()
|
|
address = models.JSONField()
|
|
# key_weiuser = models.ForeignKey(to=weiuser, on_delete=models.SET_NULL, null=True,blank=True, ) ## 删除用户时,级联删除地址
|
|
isDefaultAddress = models.CharField(choices=choicesAddress, max_length=120, )
|
|
dateAndTime = models.DateTimeField(auto_now_add=True, db_comment="创建时间") # 数据创建时间
|
|
updateTime = models.DateTimeField(auto_now=True, db_comment="更新时间") # 更新时间(需要用 save() )
|
|
|
|
class Meta:
|
|
db_table = "weiuser微信用户地址" # 给数据表自定义一个名称;默认的会是在 应用名+类名
|
|
app_label = models_app_name
|
|
ordering = ["-id_主键_配送地址", ]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pass
|
|
user = weiuser.objects.get(unionid="")
|