On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote:
> Hi,
> Suppose I have two classes in "models.py", namely A and B. And there
> is the manager for B as BManager in "managers.py". BManager makes use
> of clas A.
> 
> This situation leads to circular imports between "managers.py" and
> "models.py" for which I can't find a solution.
> 
> Assuming that I need to separate models and manager into different
> files, so merging them is not an option, are there any best practices
> or do you have any other suggestions?

No expert on Django, and it's hard to tell what your GOAL is from this
description, but you might want I'd write something like this:

class Employee(models.Model):
        name = models.CharField(...)

class Manager(Employee):
        manager_stuff...

class Worker(Employee):
        worker_stuff...
        manager = models.ForeignKey(Manager,related_name="subordinates",
blank=True, null=True)

class WorkerTypeA(Worker):
        workera_stuff..

class WorkerTypeB(Worker):
        workerb_stuff...

class ManagerB(Manager):
        a_person = ForeignKey(
        more_manager_b_stuff...

Again, depending on what your goal is, you might not even need that
a_person field now, since Workers can have managers, and managers can
have subordinates.

-- 
Lee



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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