Странно, раньше это работало, а теперь нет:
получаю следующую ошибку:
Exception Value:
'module' object is not callable
Exception Location: C:\work\Portman\core\models\pmo_review_task.py in save, line 38
если я изменю «из core.models import sc_review_task» на «из core.models import *», сообщение об ошибке изменится на «глобальное имя sc_review_task не определено».
если я запускаю django admin и выполняю:
из core.models import sc_review_task
a = sc_review_task ()
все выглядит нормально - сообщений об ошибках нет.
пожалуйста, помогите мне разобраться, я теряю волосы:)
pmo_review_task (строка 38 «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(default=datetime.now())
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):
return self.project_phase_to_review.project.name
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
self.project_phase_to_review.save()
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
self.project_phase_to_review.save()
#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
newtask.save()
#call real save operation
super(pmo_review_task,self).save(*args, **kwargs)
class Meta:
app_label = 'core'
sc_review_task:
# -*- 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
self.project_phase_to_review.save()
elif self.is_closed:
self.project_phase_to_review.is_closed = True
self.project_phase_to_review.save()
new_phase = project_phase()
new_phase.project = self.project_phase_to_review.project
new_phase.phase = self.review_decision_phase
new_phase.save()
class Meta:
app_label = 'core'
каждый из классов находится в своем собственном файле в / models /, а вот init .py:
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',
'groups',
'phases',
'pmo_review_task',
'priorities',
'progress_indicator',
'project',
'project_imported_from_excel',
'project_phase',
'project_phase_history',
'project_status_submit_form',
'roles',
'sc_event',
'sc_review_task',
'milestone',
'milestone_history']