开发者

Django: Creating a model instance when duplicate model names exist

开发者 https://www.devze.com 2023-01-07 19:25 出处:网络
In one of my views I am importing models from two apps: from mysite.business.models import Location from mysite.directory.models import Location

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 requi开发者_如何学Gore?


Give them different names.

from mysite.business.models import Location as BusinessLocation
from mysite.directory.models import Location as DirectoryLocation
0

精彩评论

暂无评论...
验证码 换一张
取 消