这是我的 models.py 文件:
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class CategoryList(models.Model):
Category = models.CharField(max_length=200)
Cat_Img = models.ImageField(upload_to='cat_media')
Active = models.BooleanField(default=True)
class ImgDetails(models.Model):
Img = models.ImageField(upload_to='media')
Category = models.ForeignKey(CategoryList, default=1, on_delete=models.SET_DEFAULT, null=False)
keywords = models.CharField(max_length=255)
UserDetail = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
Valid = models.BooleanField(default=False)
UploadDate = models.DateTimeField(auto_now_add=True)
我正在尝试在ImgDetails
with上添加外键约束CategoryList
。它正在抛出错误
from cam_project.cam_app.models import CategoryList
ModuleNotFoundError: No module named 'cam_project.cam_app'
我尝试导入from cam_project.cam_app.models import CategoryList
但仍然没有任何进展。任何建议,将不胜感激。