Mám dvě aplikace(přední a lrnadmin) v projektu(portál) tohle je můj kořenový adresář
problém je, že když jsem importovat modely v sobě to mi dává chybu
V tomto modely chci Kvalifikace jako Cizí klíč, který důvod, proč chci, dovozní Kvalifikace z lrnadmin.modely
this is my front.models.py
from datetime import datetime, timezone
from django.db import models
from django.db.models import expressions
from django.db.models.base import Model
from django.utils import timezone
from lrnadmin.models import Qualification
class Staff(models.Model):
"""Model definition for Staff."""
# TODO: Define fields here
nStaff = models.CharField(max_length= 50)
role = models.CharField(max_length= 50)
lrnQ = models.ForeignKey(Qualification, on_delete= models.CASCADE)
relQ = models.CharField(max_length=200)
relE = models.CharField(max_length=200)
# Cv = models.CharField(max_length=100, blank=True, null=True)
# Doc = models.CharField(max_length=100, blank=True, null=True)
sec7 = models.ForeignKey(Sec7, on_delete=models.CASCADE)
class Meta:
"""Meta definition for Staff."""
verbose_name = 'Staff'
verbose_name_plural = 'Staffs'
# def __str__(self):
# """Unicode representation of Staff."""
# pass
a v tomto modely chci Uživatelská jako Cizí klíč, který důvod, proč chci importovat Uživatele z fronty.modely
this is my lrnadmin.models.py
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils import timezone
from front.models import User
class CentreCode(models.Model):
"""Model definition for CentreCode."""
# TODO: Define fields here
user = models.ForeignKey(User, on_delete= models.CASCADE)
centreCode = models.CharField(max_length= 20)
categories = models.CharField(max_length = 20)
authorisation = models.CharField(max_length= 20)
registrationType = models.CharField(max_length= 20)
class Meta:
"""Meta definition for CentreCode."""
verbose_name = 'CentreCode'
verbose_name_plural = 'CentreCodes'
# def __str__(self):
# """Unicode representation of CentreCode."""
# pass
Jak mohu zvládnout
File "E:\lrn\portal\lrnadmin\models.py", line 4, in <module>
from front.models import User
File "E:\lrn\portal\front\models.py", line 7, in <module>
from lrnadmin.models import Qualification
ImportError: cannot import name 'Qualification' from partially initialized module 'lrnadmin.models' (most likely due to a circular import) (E:\lrn\portal\lrnadmin\models.py)