Saturday, May 27, 2023

Re: 'WSGIRequest' object has no attribute 'Files'


On Sun, May 28, 2023, 2:21 AM Ryan Nowakowski <ryan@fattuba.com> wrote:
I believe it should be all lower case request.files


On May 22, 2023 4:36:36 AM AKDT, Sanket Chudasama <sanket.dev025@gmail.com> wrote:
p_form  = ProfileUpdateForm(data= request.POST, files= request.Files, instance = request.user)

On Tuesday, 16 April 2019 at 12:35:15 UTC+5:30 Soumen Khatua wrote:
Hi Folks,
I'm getting this error 'WSGIRequest' object has no attribute 'Files' and i didn't get proper solution in google also. I alredaty took enctype="multipart/form-data" in my forms tag. Here is my code snippet please provide me the solution it's urgent.

Thank you in advance.

.html

  <form class="" method="post"  enctype="multipart/form-data">
                {% csrf_token %}
                {{ p_form.as_p }}
                <input type="submit" name="" value="Change">
  </form>


models.py

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio =  models.TextField(blank=True, null=True)
    image = models.ImageField(default='profile/default.jpg', upload_to='profile')

views.py

def profile_view(request):
if request.method == 'POST':
print("this is update form post method")
p_form = ProfileUpdateForm(request.POST,request.Files,instance =                                                                                          request.user.profile)
if  p_form.is_valid():
                              p_form.save()
                              return redirect('profile')

Error:
'WSGIRequest' object has no attribute 'Files'



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/81312FDA-D855-460D-8F04-04CB112F629E%40fattuba.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BZJHEoSCMeLPmcYf148iK0ACDPmGx9_gB6zkNav_UBNdmNtmg%40mail.gmail.com.

No comments:

Post a Comment