Display Video inside a Text field -Django Templates

237 views
Skip to first unread message

Nikhil Verma

unread,
Apr 27, 2012, 10:56:36 PM4/27/12
to django...@googlegroups.com

Hi All

I have a TextField to which after applying css it looks like a markup editor where i write some text, paste file links upload image etc.Now  if the user paste a video link to that editor the video should display inide that editor/TextField like in other websites eg: facebook(On click Video link it displays on the same page).

Can anybody tell me the steps how can i play the video inside a TextField ?

I searched lot about iframe.In my template i have the textfield in which the user paste the link of video saves it and it displays.Now if the user click on that video link the video should display inside  that markup editor/textfield.

My views :-

def edit_post(request, post_id):

    from djangobb_forum.templatetags.forum_extras import forum_editable_by

    post = get_object_or_404(Post, pk=post_id)
    topic = post.topic
    if not forum_editable_by(post, request.user):
        return HttpResponseRedirect(post.get_absolute_url())
    form = build_form(EditPostForm, request, topic=topic, instance=post)
    if form.is_valid():
        post = form.save(commit=False)
        post.updated_by = request.user
        post.save()
        return HttpResponseRedirect(post.get_absolute_url())

    return {'form': form,
            'post': post,
           }


Template

{% if post.user.forum_profile.signature %} <div class="postsignature"> <br /> {{ post.user.forum_profile.signature|safe }} # This is the textfield. </div> {% endif %}
 
--
Regards
Nikhil Verma
+91-958-273-3156

Pratik Mandrekar

unread,
Apr 28, 2012, 3:39:39 PM4/28/12
to Django users
Hi,

You will need to identify the video url in the post, then depending on
the url try do some processing, like getting the title or thumbnail
and render it back to your template. If you want to play the video,
you will need a video player. Eg. If it is a youtube link, then embed
the youtube player and use youtube api's if needed to render and load.


Pratik Mandrekar

Nikhil Verma

unread,
Apr 28, 2012, 3:45:35 PM4/28/12
to django...@googlegroups.com
Hi Pratik

Thanks for the reply

{{ post.user.forum_profile.signature|safe }} contains complete text including the urls of youtube and other links.

Only youtube links will show video(i have made them displayed in iframe) and other will open in a new tab.

Currently this task have been achieved by jquery with lots of pain because i was not able to find any good solution.

Do you think jquery is the write approach.

Can you give some links how do we use youtube api integration with django templates


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages