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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:44:57+00:00 2026-05-31T08:44:57+00:00

Anyone have a quick url dispatcher example? I’ve looked at the Django documentation but

  • 0

Anyone have a quick url dispatcher example? I’ve looked at the Django documentation but I find that there isn’t a complete example that shows you how everything is working in the views.

Specifically, I’m trying to pass the “url” from one view to another. For example, I am trying to make a holiday website: if a button in “available holidays” view called “europe” is clicked, I want to go to http://www.example.com/selected/europe, where all european holidays are displayed
while if a button in the available holidays view called “Australia” is clicked, I want to go to http://www.example.com/selected/australia where similarly australian holidays are displayed.

So far, in url.py I have:

(r'^selected/(?P<location>\w+)/$', 'app.views.selected'),

in views.py I have:

def selected(request, location)

I’m not sure where to go from there.
Also, how are things going to move from the “available holidays” view to the “selected” view…

  • 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-31T08:44:58+00:00Added an answer on May 31, 2026 at 8:44 am

    From the “available holidays” template, you should link to the locations page.

    First, add a “name” argument to your url definition:

    (r'^selected/(?P<location>\w+)/$', 'app.views.selected', name='selected_holidays'),
    

    Then, in the “available holidays” templates, link as such:

    {% url selected_holidays 'Europe' %}
    

    Of course, use the location variable if in a forloop:

    {% for location in locations %}
        <a href="{% url selected_holidays location %}">{{ location }}</a>
    {% endfor %}
    

    If location is a model, then you should add a get_absolute_url method to the model e.g.:

    from django.core import urlresolvers
    
    class Location(models.Model):
        # ... [snip]
        def get_absolute_url(self):
            return urlresolvers.reverse('selected_holidays', args=(self.location_name,))
    

    Then in the template:

    {% for location in locations %}
        <a href="{{ location.get_absolute_url }}">{{ location }}</a>
    {% endfor %}
    

    In that case, change the name of the url from ‘selected_holidays’ to ‘location_detail’ if it makes sense – that’s quite a standard in Django.

    If you want to be forward compatible, load the future url tag as such:

    {% load url from future %}
    

    Then, use a named url string with quotes:

    {% url 'selected_holidays' 'Europe' %}
    

    Well I think you got some starters here. You should also overread Django urls manual to know where’s what in case of troubble 🙂 https://docs.djangoproject.com/en/dev/topics/http/urls/

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

Sidebar

Related Questions

Does anyone have a quick example of how Associations, @NS and @NV work in
Anyone have a quick method for de-duplicating a generic List in C#?
Anyone have a decent example, preferably practical/useful, they could post demonstrating the concept?
Hi all I have a variable that is a YouTube url that is user-generated.
I've found tons of examples on file IO, but nothing with folders? anyone have
I see that fiver have implemented an instant pay feature with paypal. Does anyone
Does anyone have a quick and easy method for removing dynamically added buttons from
Question: Does anyone have a quick way for removing all the extra resources in
I am trying to find an integer type length in C. Does anyone have
Anyone have experience with Quick Sequence Diagram Editor ? The combination of instant display

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.