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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:57:59+00:00 2026-05-20T18:57:59+00:00

Given a view like this: # my_app/views.py def index(request): … def list(request): … def

  • 0

Given a view like this:

# my_app/views.py
def index(request):
    ...
def list(request):
    ...
def about(request):
    ...

Instead of explicitly declaring the urls in urls.py for each method in the view:

# urls.py
url(r'^index$', 'my_app.views.index'),
url(r'^list$', 'my_app.views.list'),
url(r'^about$', 'my_app.views.about'),
...

Is it possible to just give the URL dispatcher the view (my_apps.views) and have it handle all the view’s methods?

  • 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-20T18:57:59+00:00Added an answer on May 20, 2026 at 6:57 pm

    I suppose you can have one view that captures a url regexp,

    r'^(?P<viewtype>index|list|about)/$', 'myview'

    with a view that handles the captured parameter.

    def myview(request, viewtype):
        if viewtype == 'index':
              return http.HttpResponse("I'm the index view")
        elif viewtype == 'list':
              return http.HttpResponse("I'm the list view')
    

    But I’d really recommend keeping your view logic separated for clarity. It’s much easier to follow 3 different views with their specific functions than 3 if / then statements.

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

Sidebar

Related Questions

I'd like to make sure a given view in my test is fetching an
Given an ASP.NET MVC view that generates a table of entries using a for
How do I view the grants (access rights) for a given user in MySQL?
In my WPF application I have a View that is given a ViewModel, and
I can see that Collections.unmodifiableSet returns an unmodifiable view of the given set but
I have a Django project. Given a url, how can I know which view
Given a specific DateTime value, how do I display relative time, like: 2 hours
In the iPhone app I'm currently working on, I'd like two view controllers (I'll
I am creating a Rails App (I'd like to know how to do this
I'm asking this question given my chosen development frameworks of JPA (Hibernate implementation of),

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.