The 'module' object is not callable in the server execution but ok in the django console


Weirdly, it has worked before and now it doesn't:

getting the following error:

Exception Value:
'module' object is not callable
Exception Location: C:\work\Portman\core\models\ in save, line 38

if I change "from core.models import sc_review_task" to "from core.models import *" the error message will change to "global name sc_review_task is not defined."

if I run django admin and do: from core.models import sc_review_task a = sc_review_task()

it all looks ok - no error messages.

please help me figure this out, I'm loosing hair :)

pmo_review_task (line 38 is "newtask = sc_review_task()"):

# -*- coding: utf-8 -*-
from django.db import models
from datetime import datetime
from django.contrib.auth.models import User
from core.models import sc_review_task

class pmo_review_task(models.Model):
    project_phase_to_review = models.ForeignKey('project_phase')
    creation_date = models.DateTimeField(
    is_closed = models.BooleanField(default=False,null=False)
    review_date = models.DateTimeField(null=True,blank=True)
    review_comment = models.TextField(null=True, blank=True)
    reviewed_by = models.ForeignKey(User, null=True, blank=True)
    is_review_result_ok = models.NullBooleanField(null=True)
    scheduled_sc = models.ForeignKey('sc_event', null=True, blank=True)
    review_goal = models.ForeignKey('phases')

    def __unicode__(self):

    def save(self, *args, **kwargs):

        if self.is_closed and self.is_review_result_ok and self.scheduled_sc is None:
            raise models.ImproperlyConfigured

        if self.is_closed and self.is_review_result_ok is False:
            self.project_phase_to_review.is_finished = False
            self.project_phase_to_review.is_approved_for_sc = False

        if self.is_closed and self.is_review_result_ok and self.scheduled_sc:
            if self.scheduled_sc.has_taken_place is True:
                raise Exception("Cannot assign a task to a SC event that has taken place")
            #update reviewed project to indicate it has been saved
            self.project_phase_to_review.is_approved_for_sc = True
            #create sc_review_talk
            newtask = sc_review_task()
            newtask.project_phase_to_review = self.project_phase_to_review
            newtask.sc_event_to_review_at = self.scheduled_sc
            newtask.review_goal = self.review_goal
            newtask.is_closed = False
            #call real save operation
        super(pmo_review_task,self).save(*args, **kwargs)

    class Meta:
        app_label = 'core'


# -*- coding: utf-8 -*-
from django.db import models
from core.models import project_phase

class sc_review_task(models.Model):
    sc_event_to_review_at = models.ForeignKey('sc_event', null=False)
    project_phase_to_review = models.ForeignKey('project_phase', null=False)
    review_goal = models.ForeignKey('phases',related_name="target_review_goal")
    is_closed = models.BooleanField(default=False)
    review_decision_phase = models.ForeignKey('phases', null=True, blank=True,related_name="sc_decided_phase")
    review_decision_comment = models.TextField(null=True, blank=True)

    def __unicode__(self):
        return self.project_phase_to_review.project

    def save(self, *args, **kwargs):
        super(sc_review_task,self).save(*args, **kwargs)
        if self.is_closed and self.project_phase_to_review.phase == self.review_decision_phase:
            self.project_phase_to_review.is_approved_for_sc = False
            self.project_phase_to_review.is_finished = False
            self.project_phase_to_review.is_closed = False
        elif self.is_closed:
            self.project_phase_to_review.is_closed = True
            new_phase = project_phase()
            new_phase.project = self.project_phase_to_review.project
            new_phase.phase = self.review_decision_phase

    class Meta:
        app_label = 'core'

each of the classes sits in its own file within /models/ and here is the

from divisions import divisions
from django.db import models
from groups import groups
from phases import phases
from pmo_review_task import pmo_review_task
from priorities import priorities
from progress_indicator import progress_indicator
from project import project
from project_imported_from_excel import project_imported_from_excel
from project_phase import project_phase
from project_phase_history import project_phase_history
from project_status_submit_form import project_status_submit_form
from roles import roles
from sc_event import sc_event
from sc_review_task import sc_review_task
from milestone import milestone
from milestone import milestone_history

__all__ = ['divisions',

Check your namespaces...

in pmo_review_task (line 38 is "newtask = sc_review_task()") it should be newtask=sc_review_task.sc_review_task()