现在有数据表如下,表中有字段是根据其他表来填写的,我做了一个choices来做下拉框,可是现在有问题就是用户新注册后,地址栏没有数据,重启django后地址栏才会有数据
# 用户表
class Userinfo(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=16, verbose_name='名字')
code = models.CharField(max_length=16, verbose_name='工号', null=True, blank=True, unique=True)
password = models.CharField(max_length=88, verbose_name='密码')
isenable = models.BooleanField(default=False, verbose_name='是否启用')
try:
choices = [(i.ID, i.getaddressname) for i in addresschildren.objects.all()]
except Exception as e:
print(e)
choices = []
address_id = models.IntegerField(verbose_name='用户注册地', null=True, blank=True, choices=choices)
try:
choices = [(i.ID, i.Name) for i in address.objects.all()]
except:
choices = []
super_address_id = models.IntegerField(verbose_name='用户管理范围', null=True, blank=True, choices=choices)
config = configparser.ConfigParser()
try:
config.read(configsys.objects.get(name="config").value)
except ObjectDoesNotExist:
path = r'apps/config/config.ini'
config.read(path)
except Exception:
path = r'apps/config/config.ini'
config.read(path)
choices = [(int(i[-1]), i[0]) for i in config.items('jurisdiction')]
super_number = models.IntegerField(verbose_name='用户管理权限', null=True, blank=True, choices=choices, default=1)
新地址,新用户,地址栏无显示
下拉菜单也无法找到刚刚注册的地址
重启django后
请问该如何让django数据库中数据更新后能实时拿到数据并在这个方法中显示