Sorry, the image file wasnt uploaded.


On Wed, Apr 17, 2019 at 12:04 PM Aakash Baranwal <[email protected]>
wrote:

> Hi Everybody,
>
> I am trying to upload a file, but it says "No file chosen", even when I
> have selected the file. However it is getting uploaded when I have logged
> in as as admin and i am uploading it from there.
>
> Kindly help me, thanks in advance.
>
> views.py file:
>
> class VideoCreateView(CreateView):
> form_class = VideoModelForm
> fields = ['Video_Description','videofile']
> template_name = 'deploy/create_view.html'
>
> success_url = "/video/create/"
>
> def form_valid(self, form):
> form.instance.user = self.request.videofile
> return super(VideoCreateView, self).form_valid(form)
>
>
> models.py file:
>
> class Video(models.Model):
>     Video_Description= models.CharField(max_length=500)
>     videofile= models.FileField(upload_to='videos/', null=True,
> verbose_name="")
>     timestamp   = models.DateTimeField(auto_now_add=True)
>
>     class Meta:
>     ordering = ['-timestamp']
>
>
>     def __str__(self):
>         return self.Video_Description + ": " + str(self.id)
>
>
> urls.py file:
>
>
> url(r'^create/$', VideoCreateView.as_view(), name='create')
>
>
> create_view.html :
>
> <form class='form' method="POST" action="">
> {% csrf_token %}
> {{ form.as_p }}
> <input type="submit" value="Upload" / >
> </form>
>
> PFA the image file displaying the page after i selected the file and hit
> the Upload Video button
>
> With Kind Regards
>
> Aakash Baranwal
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9hQ2eq0np-THVoQOBJ6ux3fqw%2BzA1DM4DBHshTP5dMNat2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to