On Dec 1, 5:29 pm, garagefan <[email protected]> wrote: > Now, i've read the thread in regards to putting the import in the > __init__.py > > here is my structure > > website_project > - > signals > - - > signals.py (and an __init__.py) > - > shared_apps (link to numerous apps shared amongst other projects) > - - > gallery application > > my signals.py looks like this > > from django.db.models.signals import post_save > from django.core.mail import send_mail > from gallery.models import Gallery > > def send_creation(sender, instance, *args, **kwargs): > if 'created' in kwargs: > if kwargs['created'] and instance.published: > send_mail('Subject here',[sender, instance.published, > args, kwargs,], '[email protected]', ['[email protected]'], > fail_silently=False) > > post_save.connect(send_creation,sender=Gallery) > > this works when in the gallery application, however... this is just a > test case, eventually i am going to be hitting up the fb graph api and > posting the website's facebook profile, and i'd prefer to keep the > gallery application useful for both facebook and non-facebook > integrated websites. > > I've attempted import signals and import signals.signals in the > website_project __init__.py. the former resulting in nothing and the > latter resulting in a "internal server failure" upon restart.
You should do this the other way round. Keep the signal definition - the `send_creation` function itself - in signals.py, but don't import Gallery there. Instead, in gallery/models.py, import the *signal*: from signals.signals import send_creation - and then do the registering at the bottom of that file. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

