Hello, I have a project where I want to use the table from the many to many relationship, but I can’t.
here is the error i have in the console : ImportError: cannot import name ‘Motif_Document’ from ‘Motif.models’ (C:\Users\ugb\Desktop\TRF\Motif\models.py)
indeed I have three models: pattern, Document and Folder:
Model Document:
from turtle import mode
from django.db import models
Create your models here.
class Document(models.Model):
designation=models.CharField(max_length=50)
create_time=models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.designation
Model Pattern :
from tkinter import CASCADE
from turtle import mode
from django.db import models
from Document.models import Document
Create your models here.
class Motif(models.Model):
m_designation=models.CharField(max_length=50)
document=models.ManyToManyField(Document)
create_time=models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.m_designation
class Contenir (models.Model):
motif=models.ForeignKey(Motif, on_delete=models.CASCADE)
document=models.ForeignKey(Document, on_delete=models.CASCADE)
def __str__(self):
return self.motif
Model Folder :
from django.db import models
from Motif.models import Motif_Document
from Agence.models import Agence
Create your models here.
class Dossier(models.Model):
statut=(('Valider ','Valider en Agance'),
('Valider controle BEAC','Valider controle BEAC'),
('Rejeter Controleur BEAC','Rejeter Controleur BEAC')
)
devise=(('Euro','EUR'),
('Dollar Americain', 'USD'),
('YEN','JPY'),
('MAD','MAD')
)
agence=models.ForeignKey(Agence,null=True,on_delete=models.SET_NULL)
raison_sociale=models.CharField(max_length=50)
Numero_de_Compte=models.CharField(max_length=50)
motif=models.ForeignKey(Motif_Document, null=True,on_delete=models.SET_NULL,)
devise=models.CharField(max_length=50,choices=devise,default='EUR')
cours=models.FloatField(default=650)
mt_devise=models.FloatField()
beneficiaire=models.CharField(max_length=50)
statut=models.CharField(max_length=50,choices=statut,default='Valider en Agance')
create_time=models.DateTimeField(auto_now_add=True)