16👍
✅
I had pre_save and post_save signal triggers on my Company model. These were not checking the raw
param and were trying to do some smart things on database values which did not exist.
1👍
When fixture files are processed, the data is saved to the database as is. Model defined save() methods are not called, and any pre_save or post_save signals will be called with raw=True since the instance only contains attributes that are local to the model what-s-a-fixture.
from django.db.models.signals import post_save
from .models import MyModel
def my_handler(**kwargs):
# disable the handler during fixture loading
if kwargs['raw']:
return
...
post_save.connect(my_handler, sender=MyModel)
- [Django]-Custom settings and wsgi in django 1.10 give me error
- [Django]-Django-allauth: custom signup form for socialaccount
- [Django]-Testing a Django app in many separate threads
- [Django]-Celery 4.0.0 and Class based task workflow
- [Django]-Django Rest Framework IsAuthenticated permission Error Anonymous user
Source:stackexchange.com