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 6765389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:42:22+00:00 2026-05-26T14:42:22+00:00

In urls.py: (r’^bbb/id(?P<user_id>[0-9]+)/$’, ‘django.views.generic.simple.direct_to_template, {‘template’: ‘some.html’, ‘extra_context’: {‘user_id’: user_id}}), In some.html: {{ user_id }}

  • 0

In urls.py:

(r'^bbb/id(?P<user_id>[0-9]+)/$', 'django.views.generic.simple.direct_to_template,
    {'template': 'some.html', 'extra_context': {'user_id': user_id}}),

In some.html: {{ user_id }}

But there is an error: name 'user_id' is not defined (in urls.py)

So, how to declare that variable in urls.py and send it directly to ‘some.html’???

Thanks.

  • 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-26T14:42:23+00:00Added an answer on May 26, 2026 at 2:42 pm

    You don’t need to put it in extra_context. It’s already captured in the URL, so is present in the params dictionary in the template: {{ params.user_id }}.

    See the documentation – and also note that these old function-based generic views are deprecated, and you should be using the class-based TemplateView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

urls.py url(r'^some/page/$', views.some_page, {'template_name': 'some/page.html'}, name='some_page'), views.py url = request.build_absolute_uri(reverse('some_page')).lower() response = HttpResponseRedirect(url) return
urls.py: url(r'^book/(?P<booktitle>[\w\._-]+)/(?P<bookeditor>[\w\._-]+)/(?P<bookpages>[\w\._-]+)/(?P<bookid>[\d\._-]+)/$', 'book.views.book', name=book), views.py: def book(request, booktitle, bookeditor, bookpages, bookid, template_name=book.html): book =
Clean URLs seem pretty simple but I'm in need of a special situation. I
# urls.py site_media = os.path.join(os.path.dirname(__file__), 'site_media' ) urlpatterns = patterns('', (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': site_media}),
My URLs for my application looks like this: (r'^admin/', include(admin.site.urls)), (r'^contractManagement/login', 'django.contrib.auth.views.login', {'template_name': 'login.html'},()),
I have some URLs, like http://www.example.com/something?param1=value1&param2=value2&param3=value3 and I would like to extract the parameters
urls.py: from django.contrib import admin admin.autodiscover() ... url(r'^admin/', include(admin.site.urls)), settings.py has active the admin
I have some URLs like these: http://plutov.by/post/cubique_zf_jquery http://plutov.by/post/mysql_useful_queries How can I with help of
I have my nice urls working fine and heading to my index.php page, but
My Django urls.py has: from django.conf.urls.defaults import patterns, include, url import admin import settings

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.