Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:48:07+00:00 2026-06-12T05:48:07+00:00

Or rather, I have the old double-import problem with Django and signals when i

  • 0

Or rather, I have the old double-import problem with Django and signals when i include the signals.py from models.py

I’d rather not have to put the “run only once” code in for the signals, but i might do that if i absolutely have to. It just seems like such a stupid hack.

Anyway,

given i have a signals.py file AND one of the signals is for one of the objects defined in models.py, HOW do i create the annotation for it?

If i include the model then i get the ol’ “circular reference” problem that Python, confusingly, still seems to be tripped up by. It is only 2012 though.

I experimented with using get_model, but that doesn’t seem to work… the signal is now called for all saves on any and all models in the models.py file.

Here is the annotation, and what it looks like now:

@receiver(pre_save, sender=get_model('myapp.models','Story'))

i also tried

@receiver(pre_save, sender=Story)

with a corresponding from myapp.models import Story above, but caused the import error described.

What do i do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:48:08+00:00Added an answer on June 12, 2026 at 5:48 am

    When stuck like this, I just register the receiver without specifying a sender, and do the model import inside the function body.

    @receiver(pre_save)
    def handler(sender, instance, created, **kwargs):
        from models import MyModel
        if not isinstance(sender, MyModel):
            return
        do_stuff()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would rather have the DB locally on their server but do not have
when you use pigServer.registerFunction, you're not supposed to explicitly call pigServer.registerJar, but rather have
I have rather large project that uses ICU regex classes. Basically it might run
I know I could solve this with a header but I'd rather not have
I can always start to write my own, but i'd rather not have to
I have a large old program which has some rather complex graphical displays (all
I have the following in the old syntax: render json: [@note.to_json(:include => { :contact
I have a rather old website that I've fed up refactoring so I'm rebuilding.
I have got an old joomla version running. Some 1.0.x. (I did not yet
I have a few usercontrols from an old Windows CE project that I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.