Skip to content Skip to sidebar Skip to footer

Django Save Image Without Using Django Forms?

I am trying to save the image without using Django forms in the media folder. The image should save in the media\seller_profile folder and its path has to be entered in a database

Solution 1:

You've left trailing commas at the end of some of the lines where you're assigning values to the profile_data object. Those commas mean that tuples will be assigned rather than the values you intend:

profile_data.email = str(request.user),
profile_data.first_name = request.POST.get(seller_char_attribute[0]),
profile_data.seller_profile_picture = request.FILES["seller profile picture"],

Removing the trailing commas from the above lines should resolve.


Solution 2:

In your profile function def profile(request):

where you are dealing with image

profile_data.seller_profile_picture = request.FILES["seller profile picture"],

Instead of this you have to use request.FILES.get()

An instead of passing the image name in list type ["seller profile picture"]you have to give only image name

So at last your line will look like this

profile_data.seller_profile_picture = request.FILES.get("seller profile picture")

Post a Comment for "Django Save Image Without Using Django Forms?"