以下是我的模型:
from django.db import models
ATTACK_TYPES = ('EXA','Example')
class AttackImage(models.Model):
title = models.CharField(max_length=255)
image = models.ImageField(upload_to='attack_images')
source_url = models.URLField(blank=True,null=True)
class AttackItem(models.Model):
attack_image = models.ForeignKey(AttackImage, on_delete=models.CASCADE)
attack_used = models.CharField(max_length=55, choices=ATTACK_TYPES)
hidden_data_found = models.BooleanField(blank=True)
我希望用户能够同时创建attackitem和attackimage,attackitem与attackimage具有foreignkey关系,如您所见。我该怎么做?提前谢谢。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐