I have a Django project with Postgresql on DigitalOcean. Strangely, when I create an object it's triplicated on the remote server and duplicated on the local machine.
Here are my models.
from django.db import models
class Instrument(models.Model):
id = models.CharField(max_length=4, primary_key=True)
def __str__(self):
return self.id
class Quote(models.Model):
instrument = models.ForeignKey(Instrument, on_delete=models.CASCADE,
related_name='quotes')
quote = models.FloatField()
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.instrument.id;
And this is how I create an object:
q = Quote(instrument=Instrument.objects.get(pk='GBP'), quote=1.2100)
q.save()
I tried creating objects in different ways:
i = Instrument.objects.get(pk='EUR')
q = Quote.objects.create(instrument=i, quote=1.2000)
I would appreciate any comments and ideas how to resolve it.
I use Apscheduler to retreive the data and store it in DB and I have 3 records in DB at each execution:
{
"instrument": "iEUR",
"quote": 2.19572761275879,
"timestamp": "2019-08-26T23:09:00.540737Z"
},
{
"instrument": "iEUR",
"quote": 2.19572761275879,
"timestamp": "2019-08-26T23:09:00.563785Z"
},
{
"instrument": "iEUR",
"quote": 2.19572761275879,
"timestamp": "2019-08-26T23:09:00.565883Z"
}