Thank you very much for both of your responses. Local imports solved
my problem.
I had previously tried this without success, apparently there was
another mistake in the code.
Upon Bruno's suggestion I gave it another try, and it worked!

The reason why I need to separate models and managers into different
files is that they have simply grown to thousands of lines.

Regards,
Polat Tuzla


On Jan 6, 3:21 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 6 jan, 13:42, Polat Tuzla <ptu...@gmail.com> 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?
>
> The import statement works fine in a method too.
>
> class BManager(...):
>    def some_method(self):
>        from models import A
>        # code here
>
> But I have hard time understanding why you couldn't put models and
> managers in the models file...
--~--~---------~--~----~------------~-------~--~----~
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