I want to create Projects with Documents
But It took time So i wanna add document after creating the projects
But I am giving Documents related details inside my request body
# Define the signal receiver function
@receiver(post_save, sender=Project)
def attach_documents_to_project(sender, instance, created, **kwargs):
if created:
attachments_data = instance.request.data.get('document')
You don't. signals, just like models are request unaware. This is a core design feature of most model-view-viewmodel (MVVM) architectures. In fact it is not even said that there is a request involved. You could also create or update or remove records with a management command [Django-doc].
These are all reasons not to use signals [django-antipatterns]† in the first place. If something is request-oriented, it belongs in a view, not in the model layer, where signals essentially reside. You can define a helper function that you then invoke in view(s) where you want to trigger this logic.
† disclosure: I am the author if that article.