1

I have my avatar in my UserProfile model in models.py file:-

class UserProfile(models.Model):
     profileuser = models.OneToOneField(User)
     handle = models.CharField(max_length=128, blank=True)
     avatar = models.ImageField(upload_to='profile_images', blank=True)

In my forms.py file:-

class UserProfileForm(forms.ModelForm):
      class Meta:
          model= UserProfile
          exclude= ('profileuser',)

In my views.py file , I am taking file data like below:-

if 'avatar' in request.FILES:
            profile.avatar = request.FILES['avatar']

I want to limit max upload image file size to 1 MB. I have gone through many answers on stackoverflow. but still unable to do this. How can I make this happen?

H.G.
  • 319
  • 1
  • 7
  • 14
  • 1
    Possible duplicate of [Django File upload size limit](http://stackoverflow.com/questions/2472422/django-file-upload-size-limit) – rnevius Aug 17 '16 at 16:30
  • Also http://stackoverflow.com/questions/6195478/max-image-size-on-file-upload – rnevius Aug 17 '16 at 16:30

0 Answers0