Model.save () is not called when Django loads?

I am redefining my save () method on the Django model, so I can perform an additional check on the health of the object. (Is save () the right place for this?)

It seems that my fixtures / initial_fixtures.yaml objects did not call the save () method. How can I check the performance of my devices?

+6
source share
3 answers

As in Django 1.5, save () is NOT called:

When archiving files are processed, the data is stored in the database as it is. Certain save () model methods are not called, and any pre_save or post_save signals will be called with raw = True, since only the instance contains attributes that are local to the model.

https://docs.djangoproject.com/en/1.9/ref/django-admin/

+8
source

The .save() method is called at boot time, as shown in https://code.djangoproject.com/browser/django/tags/releases/1.3.1/django/core/management/commands/loaddata.py?rev= 17029 # L174

If you are using a different version of the DJ, you can check this out, but I'm sure it is also called in older versions.

How do you check if your objects have a save() method?

And more about that in .save() , if sanity checks are not trivial, I don't think this is a very good idea.

+2
source

Your luminaires are supposed to be good data, not dubious inputs, so I'm not sure if you need to check them out.

You can add data to your dB through the admin or something in your application, and then export it as a tool if you need to perform some one-time initial verification.

+1
source

Source: https://habr.com/ru/post/899982/


All Articles