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 9001169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:24:02+00:00 2026-06-16T00:24:02+00:00

There seem to be quite a few issues related to circular import errors just

  • 0

There seem to be quite a few issues related to circular import errors just with models, but I seem to be getting a similar problem with my model and signal callbacks. I’m fairly new to Django, so in all likelihood it’s more to do with me not structuring my app correctly. Some code:

badges/models.py:

from django.db import models
from django.contrib.auth.models import User
from datetime import datetime
from tasks import badgeaward_callback

class Award(models.Model):
    user = models.ForeignKey(User)
    description = models.TextField(blank=False)
    award_date = models.DateTimeField('date awarded',default=datetime.now)

    def __unicode__(self):
        return self.description

class Points(models.Model):
    POINT_TYPES = (
        ('signup', 'Sign up'),
        ...etc...
    )
    user = models.ForeignKey(User)
    points = models.IntegerField()
    date = models.DateTimeField('date created',default=datetime.now)
    description = models.TextField(blank=False)
    data = models.TextField(blank=True)
    type = models.CharField(max_length=20,choices=POINT_TYPES)

    def __unicode__(self):
        return self.description

models.signals.post_save.connect(badgeaward_callback, sender=Award)

badges/tasks.py

from badges.models import Points

def badgeaward_callback(sender, **kwargs):
    award = kwargs.get('award')

    p = Points()
    p.points = 100
    p.type = 'badgeawarded'
    p.description = award.description
    p.user = award.user
    p.save()

So, models is importing badgeaward_callback (this is the error I get: cannot import name badgeaward_callback), but tasks is importing Points model – I assume this is the root cause of my error.

Any advice on how I should be structuring my app is much appreciated. Should I just put my badgesaward_callback into models.py? That works (well, no more error), but is it a good approach when later I may be adding quite a few more callback functions?

  • 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-16T00:24:03+00:00Added an answer on June 16, 2026 at 12:24 am

    In terms of better structure, instead of tasks.py rename it signals.py and from models.py

    models.signals.post_save.connect(badgeaward_callback, sender=Award)
    

    move this line to signals.py at end. Then you don’t require the import from tasks import badgeaward_callback in models.py

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there have been quite a few posts on this but none seem
On SO, there are quite a few questions about performance profiling, but I don't
In C# There seem to be quite a few different lists. Off the top
I know there are quite a few questions concerning access violations, but I have
I've searched all over looking at similar questions but unfortunately none seem to quite
There a quite a few questions in SO related to the OutOfMemoryError: Java Heap
There seem to be quite a few tutorials on how to do this, each
There are quite a few other questions similiar to this but none of them
There seem to be many questions asked about this subject here on stackoverflow, but
When designing an distributed application in Java there seem to be a few technologies

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.