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)
I want model_B to have value_4 as separate column in database table(model_B)
For this purpose, you can use computedfield:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.