Newby in django, have two question, can't find needed info.
1) I have database (SQLite) which have table scale_calibration and field weight. Other application rewrite value in field weight 1-2 times per second. Is there possibility in Django to renew this field without renew browser (F5)?
models.py:
from django.db import models
class Calibration(models.Model):
mean_weight = models.FloatField(editable=True)
hours_to_export = models.PositiveIntegerField(default=4, editable=True)
weight = models.FloatField(editable=True)
admin.py:
from django.contrib import admin
from .models import Calibration
# Register your models here.
admin.site.register(Calibration)
2) I try follow that link to make easy calculated field (that will be write to database when save), but i have no results and no error, don't understand where i did mistake.
models.py:
from django.db import models
class Calibration(models.Model):
mean_weight = models.FloatField(editable=True)
hours_to_export = models.PositiveIntegerField(default=4, editable=True)
weight = models.FloatField(editable=True)
calibration_factor = models.FloatField(editable=True)
@property
def get_calibration(self):
return self.weight/self.mean_weight
def save(self, *args, **kwarg):
self.calibration_factor = self.get_calibration()
super(Calibration, self).save(*args, **kwarg)
Please help with advise.