1
python/django tastypie로 이미지를 업로드하는 방법 인 angularjs, django 및 tastypie를 사용하고 있습니다. 내 API에 cover: null,
이 있습니다.django tastypie 이미지 업로드 angularjs
class InventoryResource(ModelResource):
cover = fields.FileField(attribute='cover', null=True, blank=True)
class Meta:
queryset = Inventory.objects.all()
resource_name = 'inventory'
list_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
detail_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
authorization = DjangoAuthorization()
authorization = Authorization()
모델 :
class Inventory(models.Model):
manufacturer = models.CharField(max_length=255, help_text="Enter inventory name")
cover = models.FileField(upload_to = 'static/images/', default = 'static/images/no-image.png')
created = models.DateTimeField(auto_now_add=True)
)
def __unicode__(self):
return '%s' % self.manufacturer