views:

45

answers:

1

In one of my views I am importing models from two apps:

from mysite.business.models import Location
from mysite.directory.models import Location

As you can see, both Models have the same name. If I want to create an instance of one of these models, how do I define which one I require?

+8  A: 

Give them different names.

from mysite.business.models import Location as BusinessLocation
from mysite.directory.models import Location as DirectoryLocation
Ignacio Vazquez-Abrams
Thanks Ignacio. I was considering this approach but hadn't found it anywhere in the Django docs. Is this the recommended way of handling the same situation when using 3rd party apps?
Matt Rowbottom
It's the standard way of handling import conflicts in Python.
Ignacio Vazquez-Abrams