Ohh thanks Tom
it helped !!
In views.py i changed ifile=request.POST.get('inputfile') to
                                        ifile=request.FILES['inputfile']
and it worked....
Thanks a lot !!!

On Fri, Apr 17, 2015 at 8:59 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Fri, Apr 17, 2015 at 3:45 PM, livelikehimanshu12
> <livelikehimansh...@gmail.com> wrote:
> > Hello friends !!
> > So my project requires me to store images on blob service of windows
> azure
> > .I am using django in visual studio express . I even have an azure
> account..
> > So I wrote the code using a lot help from internet (I was total beginner
> to
> > django when I started this project ) . My code works perfectly fine for
> > django admin interface i.e. my images are getting stored on azure blobs
> > online and using the stored URL(in my models field) I am able to access
> it
> > also.
> > I followed this url   https://pypi.python.org/pypi/azurepython3/1.7.7
> >
> > But the problem comes when I am creating my own form which will take
> image
> > As input from user and upload it to my account's blob service !
> > The image is not getting stored !! I don't know what's wrong with my
> code !!
> > It was working well when I was working with django default filesystem
> .The
> > same models.py works for admim interface but for my normal GUI it is not
> > working !!
> >
> > One more thing , I created my form as we do in normal HTML and I am not
> > using django form class !!
> > Plzz help me !! I am totally stuck .
> > I am a newbie in django !!
> > ######################################################### models.py
> >
> ###################################################################################
> > .....
> > ....
> > def get_upload_file_name(instance, filename):
> >     return "assets/uploaded_files/%s_%s" % (str(time()).replace('.','_'),
> > filename)
> >
> > class Account(models.Model):
> >     email =models.EmailField(max_length=254,primary_key= True)
> >     password =models.CharField(max_length=20)
> >     name =models.CharField(max_length=50)
> >     dob_d=models.IntegerField(max_length=2)
> >     dob_m=models.IntegerField(max_length=2)
> >     dob_y=models.IntegerField(max_length=4)
> >
> > class Accountinfo(models.Model):
> >     email = models.ForeignKey(Account,primary_key=True)
> >     pic=models.FileField(max_length=255,
> >
> storage=AzureStorage(account_name="clique",account_key="xxx",container="new-public-container"),upload_to=get_upload_file_name)
> >     about=models.CharField(max_length=254)
> >
> >     def get_thumbnail(self):
> >         thumb = str(self.pic)
> >         return thumb
> >
> > ####################################################################
> > views.py ################################################################
> > .....
> > .....
> > ....
> > def uploadpic(request):
> >     if request.method=="POST":
> >         imail=request.POST.get('inputemail')
> >         dbaccount=Account.objects.get(email=imail)
> >         ifile=request.POST.get('inputfile')
> >         print(type(ifile))
> >         iabout=request.POST.get('inputabout')
> >         account1=Accountinfo(email=dbaccount,pic=ifile,about=iabout)
> >         account1.save()
> >         print(ifile)
> >         return
>
> This isn't how to handle uploaded files - file data is stored in
> request.FILES. There is a section in the documentation explaining the
> simple file upload case, see here:
>
>
> https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/#basic-file-uploads
>
> You would be well advised to use a ModelForm to process data that you
> post to a view in order to create items:
>
>
> https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#module-django.forms.models
>
> and use an ImageField to process the file:
>
> https://docs.djangoproject.com/en/1.8/ref/forms/fields/#imagefield
>
> Cheers
>
> Tom
>
> --
> 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+unsubscr...@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/CAFHbX1KC6NvGnY_utK-ujF2nozkmWh_YQ_XW3-zHQRWwdnozMA%40mail.gmail.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+unsubscr...@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/CAPJbmvuuQeGkvJEP3WxuAeFjutvO3TZDdb9ptcqPADNMovWuUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to