Questions tagged [imagefield]

A place to store or display a graphic image.

"Image field" is a generic term that typically would belong in a or setting such as:

It appears to be a synonym for .

342 questions
11
votes
2 answers

Store list of images in django model

I am building a Django data model and I want to be able to store an array of ImageFields. Is it possible? mainimage = models.ImageField(upload_to='img', null = True) images = models.?? Thanks.
k3lf
  • 121
  • 1
  • 2
  • 6
10
votes
1 answer

Django update ViewSet

Currently I am developing a image gallery django project. The user can upload images, and later upload a 'result' to each of the images. I know that I have to override the update(...) function, but I think I need help here with the…
9
votes
2 answers

Django ImageField widget that accepts upload or external link as source

Is there a Django widget for ImageFields that provides the option to either upload an image or provide a url? I'm thinking like Summernote does (if you click the image icon) in its examples I've browsed through many apps and they are all focused on…
43Tesseracts
  • 4,617
  • 8
  • 48
  • 94
9
votes
3 answers

How to POST a nested data and list of image

There are two models: Product and Picture. Each Product can have several Pictures. I have questions when I want to create a Product using POST. How to POST a nested object containing a ImageField list? The Product model is: class…
Scofield77
  • 917
  • 10
  • 16
8
votes
5 answers

Display images in Django

I have a django app which allows users to submit an image with it. Right now my model looks like class Posting(models.Model): title = models.CharField(max_length=150) images = models.ForeignKey(Image, null=True) class Image(models.Model): …
bencunningham
  • 356
  • 1
  • 5
  • 12
8
votes
1 answer

upload image to imagefield with djangorestframework using json and test this with CURL

I have made several apis in djangorestframework. This I could test both with the html form of the api as with curl in commandline. Now I have an api to a Model with one off the fields an ImageField. I can't figure out which curl command to…
michel.iamit
  • 5,788
  • 9
  • 55
  • 74
7
votes
2 answers

How to prevent Django from changing file name when a file with that name already exists?

In my case I allow user to upload an avatar picture and use user_id as filename, simply. So there will be 1.jpg, 2.jpg, etc. However I found if I upload a new avatar for some account that already has one uploaded, let's say user #10, the new file…
x1a0
  • 9,984
  • 5
  • 22
  • 30
7
votes
2 answers

How to save an image using django imageField?

posting from an app (iOS android etc..) not a web form. class someImage(models.Model): image = models.ImageField(upload_to= settings.SHARE_IMAGE_UPLOAD_PATH) @csrf_exempt def saveImage(request): How to write the view? it receives an image in a…
Yogev Shelly
  • 1,373
  • 2
  • 13
  • 24
7
votes
1 answer

Saving BytesIO to Django ImageField

I have a web scraper that I want to download an image of the page it's scraping and save it as a "screenshot" ImageField in a Django model. I am using this code: def save_screenshot(source,screenshot): box = (0, 0, 1200, 600) im =…
Anthony Ainsworth
  • 917
  • 1
  • 7
  • 9
7
votes
4 answers

How to improve performance in SQL Server table with image fields?

I'm having a very particular performance problem at work! In the system we're using there's a table that holds information about the current workflow process. One of the fields holds a spreadsheet that contains metadata about the process (don't ask…
Paulo Santos
  • 11,285
  • 4
  • 39
  • 65
5
votes
2 answers

Django ImageField is not updating when update() method is used

I am updating some of fields in model from views.py file. All other fields are updated properly when I use Profile.objects.filter(id=user_profile.id).update( bio=bio, city=city, date_of_birth=dob, …
Jayesh Singh
  • 696
  • 1
  • 9
  • 21
5
votes
1 answer

Django save base64 string to filesystem using models.ImageField

I am trying to upload image to file system using python django. I dont have any idea on how to proceed further. in my model.py: Class Test(object): mission = models.TextField(blank=True) image =…
Tony Roczz
  • 2,366
  • 6
  • 32
  • 59
5
votes
2 answers

How to change upload_to parameter of ImageField based on field name in Django?

I would like to upload images to the media root based on the field values given by the Django admin user. Here is the code that I've written and I know that the upload_to parameter is causing the problem. But I don't know how to make it…
MiniGunnR
  • 5,590
  • 8
  • 42
  • 66
5
votes
1 answer

Django FileField storage option

I have this model: class UserProfile(models.Model): #.......... photo = models.ImageField(upload_to = get_upload_file_name, storage = OverwriteStorage(), blank = True, null = True, …
Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37
5
votes
2 answers

Saving programmatically an ImageField duplicates the image file

I'm creating some instances of the Item model shown below from a csv file. In the csv file only the name and the filename of the Item is specified. The image field is set by looking if the image exists, and if it does, set the image file to image: I…
jul
  • 36,404
  • 64
  • 191
  • 318
1
2
3
22 23