automatically set field values in django using function
Xristos Xristoou
saxri89 at gmail.com
Tue Aug 29 15:39:07 EDT 2017
I need t define some values of fields automatically in my model using function. my function get input image path and calculate and I need that calculation results to define my database fields in Django.
but first the upload image need to get the path in server and after i can to define the values..
i will test this but myfunc cant understand the image path from upload image.
here the code :
def myview(request):
uploadimages = UploadImagesForm(request.POST or None, request.FILES or None)
if uploadimages.is_valid():
# Get the images that have been browsed
if request.FILES.get('multipleimages', None) is not None:
images = request.FILES.getlist('multipleimages')
for image in images:
instance = MyModel.objects.create(field1=request.user, field2=image)
instance.field3 = myfunc(image)
instance.field4 = myfunc(image)
instance.save()
More information about the Python-list
mailing list