Django 模型 ImportError

Django models ImportError

我正在尝试创建 Django 4 项目。我在模块中和执行迁移时添加了一个新字段。 我有一个错误:

from ..users.models import Profile ImportError: attempted relative import beyond top-level package

我有项目的下一个结构:

django/devsearch/devseach/
                /project/__init.py
                |       /admin.py
                |       /apps.py
                |       /forms.py
                |       /models.py
                |       /test.py
                |       /urls.py
                |       /views.py
                /static
                /users/__init.py
                      /admin.py
                      /apps.py
                      /forms.py
                      /models.py
                      /test.py
                      /urls.py
                      /views.py

我的文件models.py: /project/models.py

from django.db import models
import uuid
from ..users.models import Profile


class Project(models.Model):
    owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.SET_NULL)
    title = models.CharField(max_length=200)
    description = models.TextField(null=True, blank=True)
    featured_image = models.ImageField(null=True, blank=True, default='default.jpg')
    id = models.UUIDField(default=uuid.uuid4, unique=True,
                          primary_key=True, editable=False)
    demo_link = models.CharField(max_length=2000, null=True, blank=True)
    source_link = models.CharField(max_length=2000, null=True, blank=True)
    tags = models.ManyToManyField('Tag', blank=True)
    vote_total = models.IntegerField(default=0, null=True, blank=True)
    vote_ratio = models.IntegerField(default=0, null=True, blank=True)
    created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title

/users/models.py

from django.db import models
from django.contrib.auth.models import User
import uuid


class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True)
    name = models.CharField(max_length=200, blank=True, null=True)
    username = models.CharField(max_length=200, blank=True, null=True)
    email = models.EmailField(max_length=500, blank=True, null=True)
    short_info = models.CharField(max_length=200, blank=True, null=True)
    bio = models.TextField(max_length=2000, blank=True, null=True)
    profile_image = models.ImageField(
        blank=True, null=True, upload_to='profiles/', default='profiles/user-default.png')
    social_github = models.CharField(max_length=200, blank=True, null=True)
    social_twitter = models.CharField(max_length=200, blank=True, null=True)
    social_youtube = models.CharField(max_length=200, blank=True, null=True)
    social_linkedin = models.CharField(max_length=200, blank=True, null=True)
    social_website = models.CharField(max_length=200, blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)
    id = models.UUIDField(default=uuid.uuid4, unique=True,
                          primary_key=True, editable=False)

如何在项目中导入用户模型?

from users.models import Profile

而不是来自

..users.models import Profile