Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:47:12+00:00 2026-06-12T15:47:12+00:00

I am trying to pass a few variables but I am having some trouble

  • 0

I am trying to pass a few variables but I am having some trouble and specifically have 3 questions.
How do I encode the url string to take into account the special characters in the string?
What is the correct regex I should use given the strings?
And how do I decode the urls that have been encoded?

view

author = 'foo'
video = 'bar123-456'
title = 'Santorum: "I'm Not a Visionary"' # in my version, it is referencing another variable so the syntax error doesn't occur. But I left it in here because I want to know how to deal with " and '.
related = 'http://gdata.youtube.com/feeds/api/users/haha/uploads?v=2&max-results=50'

url = urllib.quote('partner/' + author+ '/'+ video+'/'+ title + '/' + related)
#How do I encode this url string above to take into account the special characters in the string?

template

<a href="/{{url}}" > <img src="img.png" > </a>

urls.py

url(r'^partner/(?P<partner_name>[-\w]+)/(?P<video_id>[-\w]+)/(?P<video_title>[-\w]+)//(?P<related_feed>)/$', 'video_player'),
#do I have to add anything to the regex?

video_player function

def video_player(request, author, video, related):
    #how do I decode the urls that are encoded

edit

I tried it without related to see if it works but am still getting an error.

template:

<a href="{% url 'reserve.views.video_player' author video title   %}" >

url:

url(r'^partner/(?P<author>[-\w]+)/(?P<video>[-\w]+)/(?P<title>[-\w]+)/$', 'video_player'),

I get this error:

NoReverseMatch at /partner/BuzzFeed/
Reverse for ”video_player” with arguments ‘(‘BuzzFeed’, ‘fXkqhhIlOtA’, ‘NY Yankees: 6 Essential Pieces of Postseason Memorabilia’)’ and keyword arguments ‘{}’ not found.

full urls.py

urlpatterns = patterns('reserve.views',
    url(r'^$', 'index'),
    url(r'^browse/$', 'browse'),
    url(r'^faq/$', 'faq'),
    url(r'^about/$', 'about'),
    url(r'^contactinfo/$', 'contactinfo'),
    url(r'^search/$', 'search'),
    (r'^accounts/', include('registration.backends.default.urls')),
    (r'^accounts/profile/$', 'profile'),
    (r'^accounts/create_profile/$', 'user_profile'),
    (r'^accounts/edit_profile/$', 'edit_profile'),
    url(r'^products/(?P<product_name>[-\w]+)/reviews/$', 'view_reviews'),
    url(r'^products/(?P<product_id>\d+)/reviews/$', 'view_reviews'),
    url(r'^user/(?P<user_id>[-\w]+)/$', 'view_reviews_user'),
    #url(r'^category/(?P<category_name>[-\w]+)/$', 'view_product_category'),
    url(r'^partner/(?P<partner_name>[-\w]+)/$', 'partner_channel'),
    url(r'^partner/(?P<author>[-\w]+)/(?P<video>[-\w]+)/(?P<video_title>[-\w]+)/$', 'video_player'),
    url(r'^partner/(?P<author>[-\w]+)/(?P<video>\w+)/(?P<title>\w+)/$', 'video_player'),
    url(r'^admin/', include(admin.site.urls)),
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:47:14+00:00Added an answer on June 12, 2026 at 3:47 pm

    Pass these variables as it is to template, there use url, before sending to template just do this in view.

    View.py

    related = urllib.quote(related, safe='')
    

    template

    <a href="{% url 'path.to.video_player' author video related %}" > <img src="img.png" > </a>
    

    Url.py

    url(r'^partner/(?P<author>[-\w]+)/(?P<video>\w+)/(?P<related>\w+)/$', 'video_player'),
    

    EDIT

    If you want to go without related parameter, or if there is doubt video can also be None then just do this in your view:

    def video_player(request, author, video=None, related=None):
    

    now you can use the url by

    <a href="{% url 'path.to.video_player' author video %}" > <img src="img.png" > </a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few questions about PHP memory usage. I'm going to run some
Trying to pass in a user supplied string which has a path to the
Trying to pass a string argument to a function, which will then be used
When trying to pass a CGPoint to a method the point is passed, but
I have a bug I've been trying to track down for a few weeks
I'm having some bad luck trying to bind a uniform 4x4 matrix. I'm targeting
I'm working with a rather large query string(~30+ parameters) and am trying to pass
I'm trying to pass values between a few winforms, I've got a total of
I'm having a bit of trouble trying to get this quicksort algorithm to work
I have a few Velocity Macros (Velocimacros) I am using in some of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.