Hello,
I have a very strange error.  When a Style gets deleted I want my
signal to get called and the signal function will delete the
appropriate photo.  I created a new file called sig.py which just
contains my 'thesignal' function.  The problem arises when I do 'from
mysite.plush.models import Photo' in my sig file.  I get the error
'ImportError: cannot import name Photo.  I have no idea why it's doing
this?  I wonder if it has something to do with because I'm doing a
'from mysite.plush.sig import thesignals' from within my models.py
file.  I wonder if since both .py files are importing functions from
each other if that is causing the error.  However, in all the
documentation I've read about signals the examples do the same
thing.

Below is my code:

////////////////

models.py

from django.dispatch import dispatcher
from django.db.models import signals
from mysite.plush.sig import thesignal

class Photo(models.Model):
    photo = models.ImageField(upload_to="site_media/thumbnails/")
    thumbnail = models.ImageField(upload_to="site_media/thumbnails/",
editable=False)
    thumbnail2 = models.ImageField(upload_to="site_media/thumbnails/",
editable=False)

class Style(models.Model):
    name = models.CharField(maxlength=200, core=True)
    theslug = models.SlugField(prepopulate_from=('name',), blank=True,
editable=False)
    image = models.ForeignKey(Photo)

dispatcher.connect(thesignal, signal=signals.post_delete,
sender=Style)

///////////////

sig.py

from mysite.plush.models import Photo

def thesignal(sender, instance, signal, *args, **kwargs):
    assert False, "It got here"

//////////////////////

The problem arises whenever I add the line 'from mysite.plush.models
import Photo' from within my sig.py file.  My command prompt
immediately errors out with 'ImportError: cannot import name Photo'


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to