Relative Content

Tag Archive for python-3.xdjangosignals

Maybe a bad implementation of Django signals

I recently deployed a full stack project using Django, Gunicorn and Nginx. Briefly speaking, it is a website for a friend of mine, a space in which he can share and publish his recent activities (such as published albums, photoshoots and articles). I tried to automatize the information collections for populating a model instance by uploading a file (for a faster, cleaner and easier upload from the admin panel) using several Django signals.
My idea was: if I upload from the admin panel a perfectly formatted file (.docx), using signals and other functions I will be able to fill the information and that’s it. But, if I delete an instance (ie an Album or an Article), I’d like that this would have effects on files (I mean, delete files from the media folder on the server). Before posting my code, I’d like to tell that in developing this approach works perfectly and it’s the same for different models. Sadly, it does not in production. More precisely, the file upload works perfectly, the processing sometimes doesn’t (and I’m left with empty fields), the file deletion for some models works, for other does not at all.