Tuesday, March 24, 2015

Re: Image resizing

Hi, 

Check out the easy_thumbnails plugin. http://easy-thumbnails.readthedocs.org/en/2.1/

It automatically resizes all images to the size you want if you use it correctly.

Regards,

Andréas

2015-03-24 11:07 GMT+01:00 <akash.patni@ranosys.com>:
Hi..
can anyone please tell me how to resize the uploaded image....
This is my model
class User(models.Model):
    first_name=models.CharField(
verbose_name = "First Name *",max_length=20,blank=False)
    last_name=models.CharField(verbose_name = "Last Name *",max_length=20,blank=False)
    username=models.EmailField(verbose_name = "Email *",max_length=30,blank=False)
    password=models.CharField(verbose_name = "Password *",max_length=15,blank=False)
    dob=models.DateField(verbose_name = "DOB *" ,blank=True,null=True)
    mobileno=models.CharField(verbose_name = "Mobile No *",max_length=20,blank=False)
    houseno=models.CharField(verbose_name = "House No",max_length=10,blank=True)
    address1=models.CharField(verbose_name = "Adress1",max_length=30,blank=True)
    city=models.CharField(verbose_name = "City",max_length=20,blank=True)
    state=models.CharField(verbose_name = "State",max_length=30,blank=True)
    pincode=models.CharField(verbose_name = "Pincode",max_length=20,blank=True)
    country=models.CharField(verbose_name = "Country",max_length=30,blank=True)
    comment=models.CharField(verbose_name = "Comment",max_length=200,blank=True)
    sex=models.CharField(verbose_name = "Sex *",max_length=5,blank=False)
    image=models.FileField(verbose_name = "Image(limit 1Mb) *",blank=True,upload_to='media/')
   
    def __unicode__(self):
        return self.first_name


this is my form
class Registration(forms.ModelForm):
      password = forms.CharField(label='Password *',widget=forms.PasswordInput())
      image = forms.ImageField(label='Select a file *',help_text='max. 1 megabytes')
      class Meta:

view.py
def registration(request):
    #request.session.set_test_cookie()
    if request.method == "POST":
            regform=Registration(request.POST,request.FILES)
            if regform.is_valid():
               #item=resize_and_crop(img_path, modified_path, size, crop_type='top')
               regform.save();
               return HttpResponseRedirect('/login/')
               
            else:
                return render_to_response('registration.html',{"form":regform})
    else:
        regform=Registration()
    return render_to_response('registration.html',{"form":regform})


def show_profile(request):
    if 'username' in request.session:
         obj_user=User.objects.all().order_by('-id')
         return render_to_response("index.html",{"obj_user":obj_user,"message":"Hello World"})
    else:
        return HttpResponseRedirect('/login/')

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5938a0d0-af8a-44aa-96c4-5d234f3e2cc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUb%3DJWPh_5Fgk8YiGTsacVLab6xakpEMW2z2GK7xd71PUpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment