[英]Make a Django model class whose one of the field value is calculated by other model's fields values and it must be present in my actual Database table
from django.db import models
class model_A(models.Model):
value_1 = models.IntegerField()
value_2 = models.FloatField()
class model_B(modles.Model):
value_3 = models.FloatField()
value_4 = (model_A.value_1 - model_B.value_2)
from django.contrib import admin
# Register your models here.
from .models import model_A, model_B
model_lst = [model_A, model_B]
for i in model_lst:
admin.site.register(i)
我希望 model_B 將 value_4 作為數據庫表中的單獨列(model_B)
為此,您可以使用計算域:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.