after reading the documents
https://docs.djangoproject.com/en/dev/topics/signals/
I created this in my signal.py file:
from django.db.models.signals import post_save from django.dispatch import receiver from models import User from models import Story @receiver(post_save, sender=User) def create_initial_story(sender,instance, signal, created, **kwargs): print "helloooo!" if created: Story(user = instance, title = 'Random Stories', description="Random stories", is_closed = False, is_random = True).save()
which, from what I read, was all that I thought was necessary to do in order to send a message. Well, this is to create a new user (I use the django-registration structure). However, nothing is sent (well, the receiver method, I do nothing). I also removed the "sender = User" parameter in the @receiver annotation - leaving
@receiver(post_save)
but it did not help. Nothing is output to the console, new data is not saved ... do I need to send a signal from the user when the user is saved ?? If so, how do I do this? I use django-registration, so I have UserProfile defined ... what do I mean, where (in which file / method) would I tell the user to send a signal?
source share