我有一个产品型号,并且有一个用于上载图像的图像域。但是然后当我尝试从django-admin界面上传图像时,我一次只能上传1张图像。我想知道是否有办法可以在django界面内上传多个图像。有办法实现吗? models.py
estimate
admin.py
class Product(models.Model):
name = models.CharField(max_length=255, unique=True)
slug = models.SlugField(max_length=255, unique=True,help_text = 'Unique value for product page URL, created from name.')
brand = models.CharField(max_length=50)
sku = models.CharField(max_length=50)
price = models.DecimalField(max_digits=9, decimal_places=2)
old_price = models.DecimalField(max_digits=9, decimal_places=2,blank = True, default = 0.00)
image = models.CharField(max_length=50)
thumbnail = models.FileField(upload_to='static/images/products/thumbnails', null=True, blank=True)
productimage = models.FileField(upload_to='static/images/products/main', null=True, blank=True)
is_active = models.BooleanField(default=True)
is_bestseller = models.BooleanField(default=False)
is_featured = models.BooleanField(default=False)
quantity = models.IntegerField()
description = models.TextField()
meta_keywords = models.CharField(max_length=255,help_text = 'Comma-delimited set of SEO keywords for meta tag')
meta_description = models.CharField(max_length=255,help_text = 'Content for description meta tag')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
categories = models.ManyToManyField(Category)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('catalog:products', kwargs={'product_slug': self.slug})
def sale_price(self):
if self.old_price > self.price:
return self.price
else:
return None
class Meta:
ordering = ['-created_at']