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

  • Home
  • SEARCH
  • 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 6127693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:32:27+00:00 2026-05-23T16:32:27+00:00

Is this possible to change variable after it’s been catched by url dispatcher and

  • 0

Is this possible to change variable after it’s been catched by url dispatcher and pass it to view changed?

For example:
I’ve got following urlpattern

urlpatterns = patterns('',
    (r'^articles/(?P<article_id>\d+)/$', 'article.views.article_view'),
)

I want to change article_id before passing it to article.views.article_view

I need this, as an override. I’ve got article app which can’t be changed, but I must use it. :-/

  • 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-05-23T16:32:28+00:00Added an answer on May 23, 2026 at 4:32 pm

    Use a wrapper view. Map the URL to your own view which then calls article.views.article_view. You can then change whatever you want within you wrapper view.

    Example:

    urlpatterns = patterns('',
        (r'^articles/(?P<article_id>\d+)/$', 'article_wrapper.wrap_article_view'),
    )
    

    In article_wrapper.py:

    import article
    def wrap_article_view(request, article_id):
        article_id = modify_it(article_id)
        return article.views.article_view(request, article_id)
    

    Update:

    If you need to do the same article_id translation for several views, you can probably make the wrapper more generic. Example:

    urlpatterns = patterns('',
        url(r'^articles/(?P<article_id>\d+)/$', 
            view='article_wrapper.generic_article_wrapper',
            kwargs={'view_name':'article_view'}
        ),
    )
    

    and in article_wrapper.py:

    import article
    def generic_article_wrapper(request, article_id, view_name=None):
        article_id = modify_it(article_id)
        try:
            view = get_attr(article.views, view_name)
        except AttributeError:
            # handle invalid view name
        return view(request, article_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible? example: $('a.change').click(function(){ //code to change p tag to h5 tag });
Is it possible to change PowerPacks.LineShape smoothingMode? I tried to use this code(a class
Possible Duplicate: Can you animate a height change on a UITableViewCell when selected? This
Using JQuery it possible to clone a Div like this and change add a
Possible Duplicate: Is there some ninja trick to make a variable constant after its
Is it possible to re-write this query to restart numbering when the UName changes
Is this possible? I want to have the To:, Body, and an Attachment all
Is this possible? I am looking forward to a tutorial which explains the steps
Is this possible? I had troubles with SVN clients not being able to access
Is this possible? I can't find it anywhere.

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.