On Thu, Nov 26, 2009 at 2:35 AM, fallhunter <fallhunt...@gmail.com> wrote:

> i have this code in my tests.py:
>
> from models import *
>
> and in the models.py I have a signal handler and register it with
>
> post_save.connect( post_save_note, sender=Note )
>
> and when i run test with ./manage.py test main
>
> I found the signal handler was registered twice and executed twice,
> and I found it's because the models was imported twice.
>
> can't i put "from models import *" in the test code? what should i do?
>
>
This happens if you import the same file using two different names. Eg, here
you are importing it as 'from models import *'. In some other part of your
code, you probably have 'from foo.models import *'. Python treats them as
two different files, and hence the signal is attached twice.

Remove/rework the spurious import, and everything will work.

Cheers

Tom

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to