나는 고객이 좋아하는 공급 업체의 저장, 내 클래스 다이어그램에 (울부 짖는 이미지 참조) 할 수있는 관계를 나는 다음과 같은 관계가 만들려고 해요 : 첫 번째 응용 프로그램에서장고 manytomany 관계 2 개 이상의 앱
을 나는 사람 객체를 가지고있다. 이것은 공급자와 클라이언트에 의해 상속된다. 두 번째 애플리케이션에는 상점 객체가있다. (이것은 판매자와의 관계가 뒤떨어 지지만 클래스 다이어그램에는 보이지 않는다. 이것은 두 번째 애플리케이션이되는 이유이다.) instantied)
문제는 클라이언트가 벤더와 저장소와의 관계가 많지만 관계 클라이언트/저장소가 오류를 생성하여 app2가 isntant 응용 프로그램 1 후에 ied.
generic manytomany 관계를 만들 수있는 방법이 있습니까?
원인 클라이언트는 저장 많은 클라이언트를 가질 수 있습니다, 많은 벤더와 많은 상점을 가질 수 있고 업체는 많은 고객
내가 사용하는 코드를 가질 수 있습니다
class Store(models.Model):
name = models.CharField("Nome", max_length=100)
description = models.CharField("Descrição", max_length=300)
class Meta:
app_label = 'store'
class Person(models.Model):
first_name = models.CharField("Primeiro Nome", max_length=100)
last_name = models.CharField("Ultimo Nome", max_length=100)
class Meta:
app_label = 'core'
class Vendor(Person):
bio = models.TextField("Bio", max_length=300, blank=True)
last_update = models.DateTimeField("Ultima Atualização", auto_now=True)
class Meta:
app_label = 'core'
class Client(Person):
favorite_stores = models.ManyToManyField(Store)
favorite_vendors = models.ManyToManyField(Vendor)
class Meta:
app_label = 'core'
이 코드주고를 나 다음과 같은 오류 :
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/core/models.py", line 7, in <module>
from store.models import Store
File "/store/models.py", line 6, in <module>
from core.models import Vendor
그리고 w 관리자가보고 싶은 모자는 다음과 같이 간단합니다.
을 가지고 (순환 종속성을 피하기 위해) 직접 문자열을 사용 다음을보십시오 : https://github.com/coleifer/django-generic-m2m – Brandon