N
N
NyxDeveloper2021-01-29 14:08:23
Django
NyxDeveloper, 2021-01-29 14:08:23

Why is the object not saved to the database when the save() method is called?

I am doing in the application the transfer of rarely used objects to another database table, in order to optimize it. I ran into a strange problem, when the save() method is called, the object is simply not saved in the database. For the transfer, I made the arch() and rearch() methods for the original model and the twin model. It should have worked in theory, but it was difficult in practice. Tell me what am I doing wrong?

Transfer method in this model:

class Project(models.Model):
    def arch(self):
        arch = PrjArch()
        arch.id = self.id
        arch.name = self.name
        arch.idKontr = self.idKontr
        arch.number = self.number
        arch.summaPlan = self.summaPlan
        arch.idKontrUch = self.idKontrUch
        arch.idTip = self.idTip
        arch.idStatus = self.idStatus
        arch.idIstFin = self.idIstFin
        arch.idKv = self.idKv
        arch.idTeam = self.idTeam
        arch.expirationDate = self.expirationDate
        arch.dateDogov = self.dateDogov
        arch.dateDogovPost = self.dateDogovPost
        arch.dateGK = self.dateGK
        arch.datePostLPU = self.datePostLPU
        arch.dateVVE = self.dateVVE
        arch.utver = self.utver
        arch.idSotrInit = self.idSotrInit
        arch.description = self.description
        arch.save()


Twin model:
class PrjArch(Project):
    def rearch(self):
        #    метод выше

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-01-29
@NyxDeveloper

Perhaps because of this horror arch.id = self.id. How you do everything very strangely.
PS look at what structure your models ended up with in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question